Hi guys;
When I used Aware's SCALE_IMAGE function, it required me to enter the width and the height at design time. For example 32x32. This would work, if the original image you were scaling from was based on the same "Aspect Ratio" (128x128) , then your thumbnail would look correct.
But if the images that was stored in database, had different widths and heights, for example one could be 300x480 or 128x600 and etc. if you use the 32x32 Aspect Ratio, your thumbnails would look funky.
Since most of the time (at least in my case) I know what what my thumbnail's height is going to be, say 32, then I needed to create a formula that at runtime, Aware would figure out the width part based on the size of the original image rather than a static 32 and it would respect the Aspect Ratio.
Here is the rule I created that anytime the original images changes, Aware would create a thumbnail respecting the "Aspect Ratio" and the result comes right.
in the xx part, enter your desired thumbnail's height, say 32 or 40 or 64 or etc.
If Object.Photo WAS CHANGED then Object.Thumbnail=SCALE_IMAGE(Object.Photo,IMAGE_WIDTH(Object.Photo)/(IMAGE_HEIGHT(Object.Photo)/xx),xx)
Hope this helps!
How to - "Aspect Ratio" Scaling with Aware's SCALE_IMAGE
Re: How to - "Aspect Ratio" Scaling with Aware's SCALE_IMAGE
Here is the result
Re: How to - "Aspect Ratio" Scaling with Aware's SCALE_IMAGE
Excellent tip, Ben! Thanks for posting it.
Tom - V8.8 build 3137 - MySql / PostGres
Re: How to - "Aspect Ratio" Scaling with Aware's SCALE_IMAGE
Nice one Ben, I have struggled with this myself but didn´t think it could be solved. Great tip.
Henrik (V8 Developer Ed. - Windows)
Re: How to - "Aspect Ratio" Scaling with Aware's SCALE_IMAGE
I tested it with many sizes and shapes and works! I had to solve it, because the thumbnails were coming out strange.hpl123 wrote:Nice one Ben, I have struggled with this myself but didn´t think it could be solved. Great tip.
Re: How to - "Aspect Ratio" Scaling with Aware's SCALE_IMAGE
Need to move this thread to the tips and tricks section.
Avid Linux user....
Re: How to - "Aspect Ratio" Scaling with Aware's SCALE_IMAGE
I have already done that BUT good point and all contributors writing tips or useful stuff, please post it in the tips section or move it t the tips section. Thanks
Henrik (V8 Developer Ed. - Windows)