Skip to content

Commit

Permalink
Added getAsBufferedImage() to Thumbnail classs
Browse files Browse the repository at this point in the history
  • Loading branch information
Wen Yu authored and Wen Yu committed Apr 4, 2018
1 parent 05c76c5 commit c3aa7fe
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
5 changes: 1 addition & 4 deletions README.md
Expand Up @@ -82,10 +82,7 @@ Image metadata manipulation:

Who is using ICAFE
------------------

* ExifStock http://www.stockphoto-tools.com/ for metadata support like TIFF IPTC etc.
* StockHelper http://saranaisoft.com/en/ for metadata support like IPTC, XMP etc.
* And lots more who don't care to put something here.
I know a lot of you are using this library even for commercial purpose. That's totally fine to me as that is my intention from day one of this library. Let me know if you want your name or company to be added here to show your appreciation.

Where can I get the latest release?
-----------------------------------
Expand Down
Binary file modified bin/com/icafe4j/image/meta/Thumbnail.class
Binary file not shown.
Binary file modified bin/com/icafe4j/io/WriteStrategyII.class
Binary file not shown.
3 changes: 2 additions & 1 deletion changelog.txt
@@ -1,6 +1,7 @@
***************************
Last modified on 04/01/2018
Last modified on 04/04/2018
***************************
04Apr2018 Add getAsBufferedImage() to Thumbnail
01Apr2018 Add TIFF IRB thumbnail support to Metadata.readMetadata()
03Jan2018 Fix TIFFReader issue with fillOrder 2
14Dec2017 Replace some of the RuntimeException with customized exception in TIFFTweaker
Expand Down
13 changes: 13 additions & 0 deletions src/com/icafe4j/image/meta/Thumbnail.java
Expand Up @@ -14,6 +14,7 @@
*
* Who Date Description
* ==== ========== ==================================================
* WY 04Apr2018 Add getAsBufferedImage()
* WY 27Apr2015 Make fields protected for subclass copy constructor
* WY 10Apr2015 Changed to abstract class, added write()
* WY 09Apr2015 Added setWriteQuality()
Expand All @@ -22,6 +23,7 @@
package com.icafe4j.image.meta;

import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.OutputStream;

Expand Down Expand Up @@ -58,6 +60,17 @@ public boolean containsImage() {
return thumbnail != null || compressedThumbnail != null;
}

public BufferedImage getAsBufferedImage() {
if(dataType == Thumbnail.DATA_TYPE_KJpegRGB || dataType == Thumbnail.DATA_TYPE_TIFF)
try {
return javax.imageio.ImageIO.read(new ByteArrayInputStream(getCompressedImage()));
} catch (IOException e) {
throw new RuntimeException("Error decoding compressed thumbnail data to BufferedImage");
}
else if(dataType == Thumbnail.DATA_TYPE_KRawRGB) return getRawImage();
else return null;
}

public byte[] getCompressedImage() {
return compressedThumbnail;
}
Expand Down

0 comments on commit c3aa7fe

Please sign in to comment.