transparency changes in IM 7
transparency changes in IM 7
I'm trying to update a number of scripts to IM 7. Many involve transparency or overlays that seem to be messing up.
I still don't quite understand the changes from transparency to alpha
Does anyone have a simple this => that for conversion list of 6 to 7 ?
Here is an example :
convert black.png -fill red -opaque white -transparent black red.png
in IM 6: desired result
in im 7, it's completely blank
I still don't quite understand the changes from transparency to alpha
Does anyone have a simple this => that for conversion list of 6 to 7 ?
Here is an example :
convert black.png -fill red -opaque white -transparent black red.png
in IM 6: desired result
in im 7, it's completely blank
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: transparency changes in IM 7
See the v7 porting guide: http://www.imagemagick.org/script/porting.php
So, insert "-colorspace sRGB" after the input filename.Reading gray-scale images generate an image with only one channel. If that image is to then accept color the -colorspace setting needs to be applied to expand the one channel into separate RGB (or other) channels.
snibgo's IM pages: im.snibgo.com
Re: transparency changes in IM 7
That works great, thanks!
Re: transparency changes in IM 7
Ok, how about this one:
composite input.gif -compose src-over blend.gif mask.gif output.gif
The mask being a black and white shape.
I'm guessing I have to convert the black and white to alpha channel?
composite input.gif -compose src-over blend.gif mask.gif output.gif
The mask being a black and white shape.
I'm guessing I have to convert the black and white to alpha channel?
Re: transparency changes in IM 7
Or, this one, I'm trying to cutout a shape from the image
composite input.jpg -gravity center -compose CopyOpacity shamrock.gif -resize 400x300 out.gif
input.jpg
shamrock.gif
With im 6 I get:
with im 7 I get:
Any ideas how to adjust that?
composite input.jpg -gravity center -compose CopyOpacity shamrock.gif -resize 400x300 out.gif
input.jpg
shamrock.gif
With im 6 I get:
with im 7 I get:
Any ideas how to adjust that?
Last edited by dognose on 2019-09-16T08:40:16-07:00, edited 2 times in total.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: transparency changes in IM 7
Please show your inputs, not just the outputs.
I never use "composite" for anything. I use "convert" for v6 or "magick" for v7, with the "-composite" operation. This needs the two inputs in the opposite order.
I never use "composite" for anything. I use "convert" for v6 or "magick" for v7, with the "-composite" operation. This needs the two inputs in the opposite order.
snibgo's IM pages: im.snibgo.com
Re: transparency changes in IM 7
added the inputs above. ... with your changes still see the same problem. reversing order doesn't work though.
magick -gravity center -compose CopyOpacity input.jpg shamrock.gif -resize 400x300 -composite out.gif
magick -gravity center -compose CopyOpacity input.jpg shamrock.gif -resize 400x300 -composite out.gif
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: transparency changes in IM 7
IM 7 is more sensitive the syntax order. Your syntax is wrong. Read the input before any processing
This works for me.
magick input.jpg \( shamrock.gif -resize 400x300 \) -gravity center -compose CopyOpacity -composite out.gif
See
https://imagemagick.org/Usage/basics/#cmdline
https://imagemagick.org/Usage/compose/#compose
https://imagemagick.org/Usage/basics/#parenthesis
This works for me.
magick input.jpg \( shamrock.gif -resize 400x300 \) -gravity center -compose CopyOpacity -composite out.gif
See
https://imagemagick.org/Usage/basics/#cmdline
https://imagemagick.org/Usage/compose/#compose
https://imagemagick.org/Usage/basics/#parenthesis
Re: transparency changes in IM 7
That doesn't work, I still get the same thing.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: transparency changes in IM 7
The issue is that the aspect of the two images are not the same. So the shamrock when resized is not the same size as the input and would need the black area extended to the same size as the input. So for IM 7 on unix, try the following which works for me.
Code: Select all
magick input.jpg -set option:dims "%wx%h" \
\( shamrock.gif -resize 400x300 -background black -gravity center -extent "%[dims]" \) \
-gravity center -compose CopyOpacity -composite out.gif
Re: transparency changes in IM 7
Ok, thanks. I wouldn't have though that!
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: transparency changes in IM 7
Another method for achieving this result would be to create a transparent canvas first, then read in the main input image, then the shamrock mask. imageMagick's default behavior when doing a "-composite" operation with three inputs is to use the third image as a mask, so a command like this...
Code: Select all
magick xc:none input.jpg shamrock.gif -resize 400x300 -gravity center -composite out.gif
That transparent layer "xc:none" starts as a 1x1 canvas, so the "-resize" makes it 300x300. Since it's the first layer, the rest of the composite follows its dimensions, etc.
This command should work exactly the same way with IM v6 by using "convert" instead of "magick".