jheck88 / thumbnailator

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

Independently specify the scaling factors for width and height #19

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Per request from a user, add a new `scale` method overload to specify the 
scaling factor of the width and height independently, i.e.

  Thumbnails.of("path/to/image")
    .scale(0.6, 0.4)
    .toFile("path/to/thumbnail");

In the above code, the width will be scaled by 0.6 times, and height will be 
scaled by 0.4 times.

For example, a source image with dimensions 100 x 100 will result in a 
thumbnail that is 60 x 40. (The resulting image will not maintain the aspect 
ratio of the original.)

Background
---------------

Currently, rescaling an image by a scaling factor will maintain the aspect 
ratio of the width and height.

  Thumbnails.of("path/to/image")
    .scale(0.5)
    .toFile("path/to/thumbnail");

In the above code, if the source image is 100 x 100, the resulting image will 
be 50 x 50.

If one wants to rescale the width to 0.5 and height to 0.6, there is no simple 
one-liner that can be performed with Thumbnailator -- one would have to 
calculate the thumbnail size for each source image, and use one of the `size` 
methods to specify the final image size.

API Design Consideration
-------------------------

This new `scale` method will not maintain the aspect ratio of the original 
image unless the scaling factor for the width and height are equal. Therefore, 
unless the two factors are equal, calling the `keepAspectRatio` method should 
result in an `IllegalStateException`.

Original issue reported on code.google.com by coobird...@gmail.com on 13 Aug 2011 at 3:22

GoogleCodeExporter commented 8 years ago
Work on this issue has started and should be part of the Thumbnailator 0.3.10 
release.

Original comment by coobird...@gmail.com on 28 Aug 2011 at 3:25

GoogleCodeExporter commented 8 years ago

Original comment by coobird...@gmail.com on 28 Aug 2011 at 3:33

GoogleCodeExporter commented 8 years ago
When is 0.3.10 set to be released?

Original comment by littleki...@gmail.com on 29 Aug 2011 at 7:31

GoogleCodeExporter commented 8 years ago
I hope to get Thumbnailator 0.3.10 out on September 3rd or 4th.

Original comment by coobird...@gmail.com on 1 Sep 2011 at 3:49

GoogleCodeExporter commented 8 years ago
This feature has been implemented in Thumbnailator 0.3.10.

The new `scale(double, double)` method can be used to specify the scaling 
factors for the width and height independently.
http://thumbnailator.googlecode.com/hg/javadoc/net/coobird/thumbnailator/Thumbna
ils.Builder.html?r=0.3.10#scale%28double,%20double%29

Original comment by coobird...@gmail.com on 4 Sep 2011 at 3:03

GoogleCodeExporter commented 8 years ago
Awesome! I'll check it out tomorrow! Thanks

Original comment by littleki...@gmail.com on 7 Sep 2011 at 5:14

GoogleCodeExporter commented 8 years ago
Never mind I was running two passes on these graphics first down to .66 and
then again to my target size I discovered if I just do it once the graphics
are very smooth not sure why two passes make it so janky. I'll just skip
the first step and do it one. Why two steps? My artist sent me some of the
graphics larger than our largest format. Thanks anyways.

Original comment by littleki...@gmail.com on 4 Nov 2011 at 4:26

GoogleCodeExporter commented 8 years ago
Thank you for the follow up and glad things are working out.

Regarding the images not being smooth when resizing on two steps, I reproduced 
the problem you were having when scaling at 0.66, so I've opened a new issue. 
(Issue 25)

Once again, thank you for your valuable feedback.

Original comment by coobird...@gmail.com on 13 Nov 2011 at 6:15

GoogleCodeExporter commented 8 years ago
You are welcome, I keep using it for all sorts of stuff, recently used it
for what it was meant for thumbnails for our website lol!

Original comment by littleki...@gmail.com on 13 Nov 2011 at 8:03