How to - "Aspect Ratio" Scaling with Aware's SCALE_IMAGE

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
BenHayat
Posts: 2749
Joined: Thu Dec 23, 2010 5:48 am
Location: Fla, USA
Contact:

How to - "Aspect Ratio" Scaling with Aware's SCALE_IMAGE

Post by BenHayat »

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!
BenHayat
Posts: 2749
Joined: Thu Dec 23, 2010 5:48 am
Location: Fla, USA
Contact:

Re: How to - "Aspect Ratio" Scaling with Aware's SCALE_IMAGE

Post by BenHayat »

Here is the result

Image
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: How to - "Aspect Ratio" Scaling with Aware's SCALE_IMAGE

Post by tford »

Excellent tip, Ben! Thanks for posting it.
Tom - V8.8 build 3137 - MySql / PostGres
hpl123
Posts: 2609
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: How to - "Aspect Ratio" Scaling with Aware's SCALE_IMAGE

Post by hpl123 »

Nice one Ben, I have struggled with this myself but didn´t think it could be solved. Great tip.
Henrik (V8 Developer Ed. - Windows)
BenHayat
Posts: 2749
Joined: Thu Dec 23, 2010 5:48 am
Location: Fla, USA
Contact:

Re: How to - "Aspect Ratio" Scaling with Aware's SCALE_IMAGE

Post by BenHayat »

hpl123 wrote:Nice one Ben, I have struggled with this myself but didn´t think it could be solved. Great tip.
I tested it with many sizes and shapes and works! I had to solve it, because the thumbnails were coming out strange.
intra
Posts: 279
Joined: Thu Oct 11, 2012 1:30 pm
Location: Australia

Re: How to - "Aspect Ratio" Scaling with Aware's SCALE_IMAGE

Post by intra »

Need to move this thread to the tips and tricks section.
Avid Linux user....
hpl123
Posts: 2609
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: How to - "Aspect Ratio" Scaling with Aware's SCALE_IMAGE

Post by hpl123 »

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)
Post Reply