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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Handler
Posts: 3
Joined: 2016-08-27T19:53:02-07:00
Authentication code: 1151

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

Post 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!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

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

Post 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.
Handler
Posts: 3
Joined: 2016-08-27T19:53:02-07:00
Authentication code: 1151

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

Post 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!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

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

Post by Bonzo »

You can use Imagemagick in php through exec() - see my signature. No need to worry about classes then :)
Handler
Posts: 3
Joined: 2016-08-27T19:53:02-07:00
Authentication code: 1151

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

Post by Handler »

@Bonzo thanks for the information!
Post Reply