jheck88 / thumbnailator

Automatically exported from code.google.com/p/thumbnailator
Other
0 stars 0 forks source link

EXIF rotation information not used when using Thumbnailator.createThumbnail(File,int, int) #43

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Take an image with EXIF rotation and use the convenience method to create a 
thumbnail

What is the expected output? What do you see instead?
Since the latest version EXIF rotation information is supposed to be respected. 
This is true if you use: 
Thumbnails.of(file).size(width,height).asBufferedImage();

I would expect the same behaviour for :
Thumbnailator.createThumbnail(file, (width,height)

However, the former rotates according the EXIF and the latter does not.  
Perhaps I'm mistaken, but this seems unexpected.

What version of the product are you using? On what operating system? Which
version of Java (Sun/Oracle? OpenJDK?) ?
This is in NetBeans 7.3 (whatever JDK that uses) on OS X 10.8.3.  Your library 
seems to work on OS X btw otherwise, although I have only used a little itty 
bitty piece of it.

Please provide any additional information below.
This is not a showstopper I just thought I'd let you know.  Thanks for this 
fantastic library.  I had written my own little chunk of code and it was messy 
and hacky.  Now it's clean, and it respects the EXIF data.

Original issue reported on code.google.com by br...@fireplan.ca on 19 May 2013 at 4:40

GoogleCodeExporter commented 8 years ago
Hi,

Thank you for reporting this issue, including a detailed description of the 
problem.

Yes, I agree that the `Thumbnailator.createThumbnail(File, int, int)` method 
not using the EXIF information would not be the expected behavior.

This should not be a very difficult issue to fix (I'll just redirect the 
implementation of that method to use the `Thumbnails.of` code path) so it 
shouldn't take too long to address this.

While I'm at it, I'll look into which methods in the `Thumbnailator` class is 
actually useful, which methods should be deprecated in favor of the 
`Thumbnails.of` interface.

(As a historic note, the `Thumbnailator` class actually existed before the 
`Thumbnails.of` interface existed.)

I'm glad that you've found the library useful! :)

Original comment by coobird...@gmail.com on 27 May 2013 at 4:17

GoogleCodeExporter commented 8 years ago
I'm not sure if there is a reason for that, but EXIF data is ignored when using 
BufferedImage as a source:
    @Test
    public void testExif() throws IOException {          //run with Java 7
        BufferedImage image = ImageIO.read(new File("/home/denisk/img/upload.jpg")); //image rotated according to EXIF
        ByteArrayInputStream is = new ByteArrayInputStream(Files.readAllBytes(Paths.get("/home/denisk/img/upload.jpg")));

        Thumbnails.of(image) //this produces not rotated image
                .size(800, 600)
                .outputFormat("jpg")
                .toOutputStream(new FileOutputStream("/tmp/img-not_rotated.jpg"));

        Thumbnails.of(is) //this produces rotated image
                .size(800, 600)
                .outputFormat("jpg")
                .toOutputStream(new FileOutputStream("/tmp/img-rotated.jpg"));

    }

This seems to happen because in 
net.coobird.thumbnailator.tasks.io.BufferedImageSource#read method there is no 
use of  param.useExifOrientation() method. If there is a reason for that, 
please comment.

Original comment by denis.k1...@gmail.com on 10 Jun 2013 at 3:15

GoogleCodeExporter commented 8 years ago
Hi,

The reason using `Thumbnails.of(BufferedImage)` does not perform a rotation 
according to the Exif metadata is because the `BufferedImage` object does not 
contain Exif metadata.
(The metadata is lost when using `ImageIO.read` to obtain the `BufferedImage`.)

On the other hand, using the `Thumbnails.of(InputStream)` does allow rotation 
using Exif, because the `InputStream` is returning the byte stream of the JPEG 
image which contains the Exif metadata.

So, the issue isn't that the Exif metadata is being ignored for the 
`BufferedImage` case, it's just that the Exif metadata doesn't exist when 
handling `BufferedImage`s.

------

Note: In the future, please create a new issue if the issue you're having does 
not directly apply to the issue at hand -- this issue deals with the behavior 
of the `Thumbnailator.createThumbnail` method.

Original comment by coobird...@gmail.com on 11 Jun 2013 at 1:32

GoogleCodeExporter commented 8 years ago

Original comment by coobird...@gmail.com on 29 Jun 2013 at 6:57

GoogleCodeExporter commented 8 years ago
This issue has been addressed in Thumbnailator 0.4.5.

Original comment by coobird...@gmail.com on 30 Jun 2013 at 11:38