PSD Thumbnail fix.

This commit is contained in:
Harald Kuhr 2017-10-21 21:30:33 +02:00
parent fe379df36e
commit f14159de57
2 changed files with 7 additions and 4 deletions

View File

@ -1207,6 +1207,10 @@ public final class PSDImageReader extends ImageReaderBase {
private List<PSDThumbnail> getThumbnailResources(final int imageIndex) throws IOException {
checkBounds(imageIndex);
if (imageIndex > 0) {
return null;
}
readHeader();
List<PSDThumbnail> thumbnails = null;
@ -1240,7 +1244,7 @@ public final class PSDImageReader extends ImageReaderBase {
List<PSDThumbnail> thumbnails = getThumbnailResources(imageIndex);
if (thumbnails == null) {
throw new IndexOutOfBoundsException(String.format("thumbnail index %d > 0", thumbnailIndex));
throw new IndexOutOfBoundsException(String.format("image index %d > 0", imageIndex));
}
return thumbnails.get(thumbnailIndex);
@ -1258,7 +1262,6 @@ public final class PSDImageReader extends ImageReaderBase {
@Override
public BufferedImage readThumbnail(final int imageIndex, final int thumbnailIndex) throws IOException {
// TODO: Thumbnail progress listeners...
PSDThumbnail thumbnail = getThumbnailResource(imageIndex, thumbnailIndex);
// TODO: It's possible to attach listeners to the ImageIO reader delegate... But do we really care?

View File

@ -2397,7 +2397,7 @@ public final class TIFFImageReader extends ImageReaderBase {
// // System.err.println("Scale time: " + (System.currentTimeMillis() - start) + " ms");
// }
if (image.getType() == BufferedImage.TYPE_CUSTOM) {
if (image != null && image.getType() == BufferedImage.TYPE_CUSTOM) {
start = System.currentTimeMillis();
image = new ColorConvertOp(null).filter(image, new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB));
System.err.println("Conversion time: " + (System.currentTimeMillis() - start) + " ms");
@ -2406,7 +2406,7 @@ public final class TIFFImageReader extends ImageReaderBase {
showIt(image, String.format("Image: %s [%d x %d]", file.getName(), reader.getWidth(imageNo), reader.getHeight(imageNo)));
try {
int numThumbnails = reader.getNumThumbnails(0);
int numThumbnails = reader.getNumThumbnails(imageNo);
for (int thumbnailNo = 0; thumbnailNo < numThumbnails; thumbnailNo++) {
BufferedImage thumbnail = reader.readThumbnail(imageNo, thumbnailNo);
// System.err.println("thumbnail: " + thumbnail);