AascisB / thumbnailator

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

Make possible to obtain image parameters #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be very useful to add feature to obtain image parameters (width, 
height, etc).

Currently it's possible to get from buffered image object: 
Thumbnails.of(...).scale(1f).asBufferedImage()

Without .scale(1f) it fails with exception though it's unnecessary operation 
for the case.

Original issue reported on code.google.com by x4j...@gmail.com on 1 Oct 2012 at 11:27

GoogleCodeExporter commented 9 years ago
Thank you for the suggesting a new feature.

However, it is not within the scope of the Thumbnailator library to provide 
information about the original image.

As the objective of the Thumbnailator library is to create a thumbnail from the 
original image, using Thumbnailator without calling `size` or `scale` is not 
valid, hence the exception is thrown.

Therefore, I will not be adding a new feature to Thumbnailator to obtain 
information about the original image at this time.

-----

Just as an additional note about obtaining the width and height of the original 
image.

One way is to simply use the `ImageIO.read` method to obtain the 
`BufferedImage` representation of the image:

    BufferedImage img = ImageIO.read(new File(img));
    int width = img.getWidth();
    int height = img.getHeight();

This will read the entire image to memory, so it could be wasteful when all 
that is needed is the metadata like width and height.

There are other ways that don't require reading the entire image to memory, 
illustrated here:
http://stackoverflow.com/questions/672916/how-to-get-image-height-and-width-usin
g-java

Original comment by coobird...@gmail.com on 8 Oct 2012 at 6:00