Rotate an image ...

Dar Scott dsc at swcp.com
Sun Dec 5 14:31:20 EST 2004


On Dec 5, 2004, at 8:24 AM, Alex Tweedly wrote:

> I have a PNG file which I want to rotate 90 degrees.
>
> My script does
>    import paint from file "d:/icons/myfile.png"
>    rotate image "myfile.png" by 90
>    export image "myfile.png" to file "d:/icons/myfilerotated.png"
> which ALMOST works.
>
> It gives me an image with, at first glance, the correct appearance - 
> but the size is 100x100 so there is spurious white border. I had 
> expected to get a new image that was 100x60.
>
> Is there a way to rotate an image to get just the original image, but 
> rotated ?
> Or some other way to trim it back to original size (except rotated) ?

Here are a couple of approaches (this may take some experimenting):
1.  Set the angle, "touch" the image to rebuild the PNG, then crop it, 
if need be.
2.  Get the imageData and alphaData, rotate that by script, put empty 
into the image object, set the new size and set the rotated imageData 
and alphaData back into the image.

If you need some specific header info in the PNG, you might need to 
script that.

Dar
****************************************
     Dar Scott Consulting
     http://www.swcp.com/dsc/
     Programming Services
****************************************



More information about the use-livecode mailing list