Working with images

Getting the dimensions of an image:

<?lc
put "photo.jpg" into myImage
import paint from file myImage
put the width of last image & "px x " & the height of last image & "px"
?>

Scaling an image

e.g. To scale an image by 50%

<?lc
put "photo.jpg" into myImage
import paint from file myImage
set the resizeQuality of last image to "normal" // can be normal, good or best
put "0.5" into theScale
set the width of last image to the width of last image * theScale
set the height of last image to the height of last image * theScale
set the imageData of last image to the imageData of last image
export last image to file ("resized" && myImage)as JPEG
delete last image
?>

Cropping an image

<?lc
put "photo.jpg" into myImage
import paint from file myImage
crop image myImage to 00,00,100,120 // left,top,right,bottom
export last image to file ("cropped" && myImage) as JPEG
delete last image
?>

Flip an image

<?lc
put "photo.jpg" into myImage
import paint from file myImage
flip image myImage vertical // horizontal or vertical
export last image to file ("flipped" && myImage) as JPEG
delete last image
?>

Rotate an image

<?lc
put "photo.jpg" into myImage
import paint from file myImage
rotate image myImage by 45
export last image to file ("rotated" && myImage) as JPEG
delete last image
?>

Leave a Reply