Page 1 of 1

Affine Translate and preserve alpha

Posted: 2010-01-20T15:42:43-07:00
by latest33
Trying to translate an image that is mostly transparent. There is a set of several images (will be processed one by one) that need to have their images shifted over a set amount. However, using:

convert test.png -affine 1,0,0,1,50,100 -transform output.png

However, the image doesn't change. I read that I need to flatten.

convert test.png -affine 1,0,0,1,50,100 -transform -flatten output.png

However, this puts a white background. I'm trying to find a way to keep the alpha.

Thank you.

Re: Affine Translate and preserve alpha

Posted: 2010-01-20T16:23:45-07:00
by fmw42
what do you mean by translate / shift? what happens when you shift -- do you want to add extra area or just crop off the part shifted off the image size?

if you just want to loose some data, then just crop it to the center you need.

you can use -roll (but it has wrap around)

or you can use -distort SRT to do the translate. you may need to add -channel rgba -alpha on to preserve the transparency.

see -distort SRT http://www.imagemagick.org/Usage/distorts/#srt

use scale of 1 and angle of 0

you may need +distort to make the size bigger for the amount shifted

also see -distort affine under http://www.imagemagick.org/Usage/distor ... rol_points

that may be just what you want but use -virtual-pixel transparent for the fill-in of transparent

Re: Affine Translate and preserve alpha

Posted: 2010-01-20T16:29:20-07:00
by latest33
fmw42 wrote:what do you mean by translate / shift? what happens when you shift -- do you want to add extra area or just crop off the part shifted off the image size?

if you just want to loose some data, then just crop it to the center you need.

you can use -roll (but it has wrap around)

or you can use -distort SRT to do the translate. you may need to add -channel rgba -alpha on to preserve the transparency.

see -distort SRT http://www.imagemagick.org/Usage/distorts/#srt

use scale of 1 and angle of 0

you may need +distort to make the size bigger for the amount shifted
That seems to have done it. I appreciate that.