hupeng1991 / java-image-scaling

Automatically exported from code.google.com/p/java-image-scaling
Other
0 stars 0 forks source link

proportional scaling #23

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I have a question about image scaling which I hope is easy to answer... I think 
I am missing an obvious detail.

If I have an image of size 850x1100 pixels, and want to scale it to 136x176 -- 
no problem, just .16 of the original size in both dimensions.  The downscaled 
image fits nicely in its new dimensions.

But if I scale my 850x1100 image so that the downscaled width is 186, then I am 
downscaling by .218823529, and the height should be 240.705882px.  If I round 
up to 241 or down to 240 to do my scaling with ResampleOp, I will slightly 
distort my image.

If I could use the float value for scaling, there will be a frayed edge along 
the bottom, but I could choose to trim those if I wanted -- this is a trade-off.

Can I do proportional scaling with your library?

Original issue reported on code.google.com by jedier...@gmail.com on 28 Feb 2011 at 3:34

GoogleCodeExporter commented 8 years ago
Good question ! The library does suport proportional scaling using the 
DimensionConstrain.createRelativeDimension(float), but internally it just 
rounds off to the nearest width and height (meaning it potentially distort the 
image slightly).

Your suggestion could also work - however both solutions will remove some 
information from the image (either by changing the aspect-ratio slightly or 
removing information from the last line). 

The usual problem people have is they want to arbitrary sized-image into a 
fixed sized thumbnail - this situation is not really supported the the library 
either. The workaround is to first scale the image, and afterwards "enlarge the 
canvas" (by copying the rescaled image into a image with the correct 
dimensions).

- Morten

Original comment by m%nobel-...@gtempaccount.com on 28 Feb 2011 at 8:17