Cant seem to get transparency to work when using the command
convert $1s.jpg \( +clone -background black -rotate $2 \) -gravity center -compose Src -composite $1f.png
Tried -background none, transparent
Ubuntu Version: ImageMagick 6.8.9-9 Q16 x86_64 2018-06-11
image rotate black background transparent not working.
image rotate black background transparent not working.
Last edited by brizey02 on 2018-07-01T22:26:39-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: image rotate black background transparent not working.
JPG does not support transparency. So your input has no transparency. -compose src will not add transparency. You probably want to use -compose copy_opacity. See http://www.imagemagick.org/Usage/compose/#copyopacity
Always provide your Imagemagick version and platform when asking questions, since syntax may vary.
Always provide your Imagemagick version and platform when asking questions, since syntax may vary.
Re: image rotate black background transparent not working.
Code: Select all
convert test.png \( +clone -background 'rgba(0,0,0,0)' -rotate 75 \) -gravity center -compose copy_opacity -composite debug.png
Also
Code: Select all
convert test.jpg \( +clone -background 'rgba(0,0,0,0)' -rotate 75 \) -gravity center -compose Src copy_opacity -composite debug.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: image rotate black background transparent not working.
-background does not change the background, it is just a setting that needs an operator to work. Cloning the image does not change it to grayscale. You need to make the clone into a grayscale or binary image and then rotate both, assuming you want the alpha channel to be rotated the same as the image. Perhaps you should provide your input image by posting to some free service and put the URL here and then explain how you want the transparency to look.
I am not sure what you want for transparency, but try
or
Also your first post started with JPG. You are now starting with a PNG. Does the PNG have transparency already? If so, then just do
I am not sure what you want for transparency, but try
Code: Select all
convert test.png \( +clone -colorspace gray \) -background 'rgba(0,0,0,0)' -rotate 75 -gravity center -compose copy_opacity -composite debug.png
Code: Select all
convert test.png \( +clone -colorspace gray -threshold 50% \) -background 'rgba(0,0,0,0)' -rotate 75 -gravity center -compose copy_opacity -composite debug.png
Code: Select all
convert test.png -background none -rotate 75 debug.png
Re: image rotate black background transparent not working.
This works great but the image is resized need to matain the same size
Code: Select all
convert test.png \( +clone -colorspace gray \) -background 'rgba(0,0,0,0)' -rotate 75 -gravity center -compose copy_opacity -composite debug.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: image rotate black background transparent not working.
When you rotate an image, the bounding box gets bigger. Imagemagick does not automatically make it the same size as the original. You will need to resize it to the same original size.
If you were using IM 7, you could do it all in one command line.
If you do not want the resize and just want the image cropped, you can do
Code: Select all
dim=$(convert test.png -format "%wx%h" info:)
convert test.png \( +clone -colorspace gray \) -background none -rotate 75 -gravity center -compose copy_opacity -composite -resize $dim debug.png
If you do not want the resize and just want the image cropped, you can do
Code: Select all
dim=$(convert test.png -format "%wx%h" info:)
convert test.png \( +clone -colorspace gray \) -background none -rotate 75 -gravity center -compose copy_opacity -composite -extent $dim debug.png
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: image rotate black background transparent not working.
Maybe you'd do better to use "-distort" instead of "-rotate". Try something like this...
Code: Select all
convert input.jpg -set alpha -background none -virtual-pixel none -distort SRT 75 output.png