Image resize.

Frank D. Engel, Jr. fde101 at
Tue Oct 19 16:58:56 EDT 2004

Here is another solution.  Try putting the handler below into a stack 
or card script (I put it in my mainstack's script).  If the option (or 
alt for x86 systems) is held down after resizing, the image will 
automatically shrink to fit the given box and to maintain the original 
aspect ratio of the image.

on resizeControl
   if the first word of the abbreviated name of the target is "image" 
and the optionKey is down then
     put the height of the target into curhigh
     put the width of the target into curwide
     put the formattedHeight of the target into orighigh
     put the formattedWidth of the target into origwide

     put origwide/orighigh into aspect1
     put orighigh/origwide into aspect2

     multiply aspect1 by curhigh
     multiply aspect2 by curwide

     if aspect1 > curwide then
       set the height of the target to aspect2
     else if aspect2 > curhigh then
       set the width of the target to aspect1
     end if
   end if
end resizeControl

On Oct 19, 2004, at 5:36 PM, Derek Bump wrote:

>> very nice, Derek, very nice!
>> Could you eventually consider to give a TINY hint on how to use it?
> :)  Yes, sorry about that.  I was composing message when I got a call 
> (I work in Security with the local Police Department) so I just sent 
> it and I'm back now.
> That script is for constraining the aspect ratio for an image when a 
> new width or height is choosen.  It would consit of 2 fields, width 
> and height, and 2 option menus both containing "Pixels" and "Percent". 
>  Also, there's a checkbox to turn on/off the aspect calculator.
> The original width and height are always constant and held in the 
> variables oWidth and oHeight.  When a new width or height is entered 
> in the fields, the appropriate "doUpdate" handler is called and puts 
> the calculated width and height into the variables and then into the 
> opposite field.
> The script is not completely exact though.  Sometimes the numbers are 
> a little off when trying to get a calculation down to 1 or 2 pixels, 
> but it works pretty well.
> Derek Bump
> Dreamscape Software
> ____________________________________________
> Compress Images Easily with JPEGCompress
> _______________________________________________
> use-revolution mailing list
> use-revolution at
Frank D. Engel, Jr.  <fde101 at>

$ ln -s /usr/share/kjvbible /usr/manual
$ true | cat /usr/manual | grep "John 3:16"
John 3:16 For God so loved the world, that he gave his only begotten 
Son, that whosoever believeth in him should not perish, but have 
everlasting life.

More information about the Use-livecode mailing list