You just have to put the prefered dimensions of an image and the script resize it without stretching.
----------------------------------------------------------------------------------------
---- I M A G E R E S I Z E R v1.0 -----------------------------------------------------
---- ::: Copyright 2006 ::: -----------------------------------------------------------
---- [ Profitakis Konstantinos (proufas@mycosmos.gr) ::: BRAIN.net ::: GREECE ::: ] ----
----------------------------------------------------------------------------------------
---- How it works:
---- You have to insert the prefered image dimensions in the parameters and then, let -
---- the script work. ------------------------------------------------------------------
----------------------------------------------------------------------------------------
property spritenum, pMaxWidth, pMaxHeight
----------
on getBehaviorDescription me
return "IMAGE RESIZER v1.0" & RETURN & "Copyright 2006 - Profitakis Konstantinos (proufas@mycosmos.gr) - BRAIN.net - GREECE" & RETURN & "How it works:" & RETURN & "You have to insert the prefered image dimensions in the parameters and then, let the script work."
end
----------
on getPropertyDescriptionList me
--Dimension selection
set plist to [:]
addprop plist, #pMaxWidth, [#comment:"Max width of image", #format:#integer, #default:0]
addprop plist, #pMaxHeight, [#comment:"Max height of image", #format:#integer, #default:0]
return plist
end
----------
on beginsprite
--Gets the initial dimensions
mySprite=sprite(spritenum)
InitImageWidth=mySprite.width
InitImageHeight=mySprite.height
--Checks if image is landscape or portrait
if InitImageWidth>InitImageHeight then
ImageType="landscape"
else
ImageType="portrait"
end if
--Makes the calculation
if ImageType="landscape" then
ratio=(InitImageHeight.float)/(InitImageWidth.float)
FinalImageWidth=pMaxWidth
FinalImageHeight=pMaxWidth*ratio
end if
if ImageType="portrait" then
ratio=(InitImageWidth.float)/(InitImageHeight.float)
FinalImageWidth=pMaxHeight*ratio
FinalImageHeight=pMaxHeight
end if
--Final step and centers the registration point of the image
sprite(spriteNum).member.centerRegPoint=1
mySprite.width=FinalImageWidth
mySprite.height=FinalImageHeight
end
----------
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA