Image resize.

Derek Bump webmaster at dreamscapesoftware.com
Tue Oct 19 17:14:32 EDT 2004


> This bugs me too.  Is anyone aware of a simple Transcript workaround 
> (to constrain the size during resize using a script), or should I start 
> trying to be clever here?

This should help...


global oWidth,oHeight,newWidthPixels,newWidthPercent,newHeightPixels,newHeightPercent

--  For the Width

on doUpdate
put (word 2 of the selectedLine of btn "widthUnit") into widthUnit
put (word 2 of the selectedLine of btn "heightUnit") into heightUnit
if (the text of me is empty) or ((the text of me) < 1) then put 1 into me
if widthUnit = "1" then 
-- Calculate via Pixels
put (the text of me) into newWidthPixels
put (oWidth * 0.01) into onePercent
put the round of (newWidthPixels / onePercent) into newWidthPercent
if the hilight of button "maintainAspect" is true then
put newWidthPercent into newHeightPercent
put the round of ((oHeight * 0.01) * newHeightPercent) into newHeightPixels
end if
else
-- Calculate via Percentage
put (the text of me) into newWidthPercent
put the round of ((oWidth * 0.01) * newWidthPercent) into newWidthPixels
if the hilight of button "maintainAspect" is true then
put newWidthPercent into newHeightPercent
put the round of ((oHeight * 0.01) * newHeightPercent) into newHeightPixels
end if
end if
if heightUnit = "1" then
put newHeightPixels into fld "newHeight"
else
put newHeightPercent into fld "newHeight"
end if
end doUpdate

-- For the Height

on doUpdate
put (word 2 of the selectedLine of btn "widthUnit") into widthUnit
put (word 2 of the selectedLine of btn "heightUnit") into heightUnit
if (the text of me is empty) or ((the text of me) < 1) then put 1 into me
if heightUnit = "1" then 
-- Calculate via Pixels
put (the text of me) into newHeightPixels
put (oHeight * 0.01) into onePercent
put the round of (newHeightPixels / onePercent) into newHeightPercent
if the hilight of button "maintainAspect" is true then
put newHeightPercent into newWidthPercent
put the round of ((oWidth * 0.01) * newWidthPercent) into newWidthPixels
end if
else
-- Calculate via Percentage
put (the text of me) into newHeightPercent
put the round of ((oHeight * 0.01) * newHeightPercent) into newHeightPixels
if the hilight of button "maintainAspect" is true then
put newHeightPercent into newWidthPercent
put the round of ((oWidth * 0.01) * newWidthPercent) into newWidthPixels
end if
end if
-- Update the other Field if needed
if widthUnit = "1" then put newWidthPixels into fld "newWidth" else put newWidthPercent into fld "newWidth"
end doUpdate

 

Derek Bump
Dreamscape Software
____________________________________________
Compress Images Easily with JPEGCompress
http://www.dreamscapesoftware.com


More information about the use-livecode mailing list