Page 1 of 1

I need some help with rotating a layer from a GIMP image

Posted: 2016-08-27T20:10:37-07:00
by Handler
Hello!


In the end I'd like to be able to rotate the layer while keeping the same image dimensions and if possible crop it to the image. I know I'm asking a lot! :shock:

My GIMP image is pretty basic, it has a transparent background layer and a transparency layer above it which this is the one I'm rotating.

I wrote a simple little script to do the work but the out come is that the layer does get rotated but the image its resized. It looks rather funky and If I go an load it (the png) it gives me choices about the png offset which makes sense.

Code: Select all

#! /bin/bash
d=0
while [ $d -lt 361 ]; do
	printf -v n "%03d" $d
	convert test_b_wind_icon.xcf[1] -rotate $d ./new/b_$n.png
	((++d))
done
So ... how do I rotate the layer while keeping the images size of 300px x 300px at the same time respecting it's transparency?

I'm always grateful for the help! And this will be my one new thing learned for the day!

Thank you, once again!

Re: I need some help with rotating a layer from a GIMP image

Posted: 2016-08-27T20:16:27-07:00
by fmw42
Please post your input image to some free hosting service such as dropbox.com and put the URL here. Also please always provide your IM version and platfrom, though it seem you are on some kind of Unix system.

IM automatically expands the image size to show the fully rotated image.

To rotate and keep the same image size and the input, you need to get the input size, then rotate, then crop the image in the center to your original size. See http://www.imagemagick.org/Usage/crop/#crop_gravity

Re: I need some help with rotating a layer from a GIMP image

Posted: 2016-08-27T20:24:03-07:00
by GeeMack
Handler wrote:So ... how do I rotate the layer while keeping the images size of 300px x 300px at the same time respecting it's transparency?
You can use "-distort" to rotate an image while keeping its original size. Something like this...

Code: Select all

... -distort SRT '$d' ...
... will rotate it using the center of the image as a center point. If you want to specify a particular point as the center of the rotation you can do that with something like this...

Code: Select all

... -distort SRT '$x,$y $d' ...
Learn more about using "-distort" for rotation HERE.

Edited: Fixed error in example command.

Re: I need some help with rotating a layer from a GIMP image

Posted: 2016-08-27T20:43:51-07:00
by Handler
@GeeMack outstanding!

Worked like a charm! =)))) I batch did the cropping in GIMP which took a second. This was the main battle! =)
I've just started to dabble in the world of command line image manipulation. I've been doing some with the GD library using PHP. I'm not an object oriented programmer (learning) so imagemagick in PHP will have to wait a little while!

Thanks again! I've been bucking at this for two days now!

Re: I need some help with rotating a layer from a GIMP image

Posted: 2016-08-28T00:36:48-07:00
by Bonzo
You can use Imagemagick in php through exec() - see my signature. No need to worry about classes then :)

Re: I need some help with rotating a layer from a GIMP image

Posted: 2016-08-28T06:13:28-07:00
by Handler
@Bonzo thanks for the information!