IM copy_opacity example seems to fail
IM copy_opacity example seems to fail
a) Copy_Opacity
An example of Anthony's from http://www.imagemagick.org/Usage/compose/#copyopacity
intended to ilustrate the use of `copy_opacity'
convert -size 70x70 xc:black -fill white -draw 'circle 35,35 35,5' \
-fill black -draw 'circle 28,30 35,5' \
moon_mask.gif
convert -size 70x70 plasma:white-dodgerblue moon_mask.gif \
-alpha Off -compose CopyOpacity -composite moon_gradient.png
That, and minor variations (eg copy_opacity) do not seem to work as described,
that is, create a coloured segment of the moon..
b) Fred's textcleaner script
The script employs a line effectively as below:
convert image -colorspace gray -type grayscale -contrast-stretch 0
Why does `-type grayscale' appear when the result from the previous stage
is already greyscale?
c) Significance of a line from identify
Using identify, one line is:
Matte color: grey74 (interesting mix of US and English spelling here)
I understood from IM documentation that `matte' is used as a synonym for alpha (channel).
What does it refer to in relation to the output from `identify'?
An example of Anthony's from http://www.imagemagick.org/Usage/compose/#copyopacity
intended to ilustrate the use of `copy_opacity'
convert -size 70x70 xc:black -fill white -draw 'circle 35,35 35,5' \
-fill black -draw 'circle 28,30 35,5' \
moon_mask.gif
convert -size 70x70 plasma:white-dodgerblue moon_mask.gif \
-alpha Off -compose CopyOpacity -composite moon_gradient.png
That, and minor variations (eg copy_opacity) do not seem to work as described,
that is, create a coloured segment of the moon..
b) Fred's textcleaner script
The script employs a line effectively as below:
convert image -colorspace gray -type grayscale -contrast-stretch 0
Why does `-type grayscale' appear when the result from the previous stage
is already greyscale?
c) Significance of a line from identify
Using identify, one line is:
Matte color: grey74 (interesting mix of US and English spelling here)
I understood from IM documentation that `matte' is used as a synonym for alpha (channel).
What does it refer to in relation to the output from `identify'?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: IM copy_opacity example seems to fail
(a) Copying and pasting the moon example works for me (v6.8.7-0 on Windows 7). I get a blue plasma moon on a transparent background. What do you get? On what version and platform?
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: IM copy_opacity example seems to fail
b) Fred's textcleaner script
The script employs a line effectively as below:
convert image -colorspace gray -type grayscale -contrast-stretch 0
Honestly, I do not recall. But most likely at some release of IM that redundancy was needed. I probably left it in, since it does not harm for later releases.
Re: IM copy_opacity example seems to fail
Version: ImageMagick 6.8.7-4 2013-10-26 Q16
I use a Korn Shell command line interpreter running under Windows XP and have been
running IM scripts for many years. EG several of Fred's scripts run without change.
But "to be sure to be sure" I ran it again in XP command mode and it still failed.
The result with the copy_opacity example is a copy of the 70x70 coloured image without any moon.
I tried a nearby example using the `-dissolve' option which seems to work OK.
Regards
I use a Korn Shell command line interpreter running under Windows XP and have been
running IM scripts for many years. EG several of Fred's scripts run without change.
But "to be sure to be sure" I ran it again in XP command mode and it still failed.
The result with the copy_opacity example is a copy of the 70x70 coloured image without any moon.
I tried a nearby example using the `-dissolve' option which seems to work OK.
Regards
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: IM copy_opacity example seems to fail
Hmm. I've just installed the current version, 6.8.7-5, on Win 7. It works fine. I assume your moon_mask.gif is okay? White moon on black background?
You probably have plenty of bug-tracking experience but I'd suggest:
- You are using a pre-compiled version? If not, perhaps your build was bad.
- Are you using the DLL version? If so, are you sure it isn't using the wrong DLLs?
- Try a different format for moon_mask, eg png or tiff instead of gif.
- If this fails for all file types, do any of the other compose methods fail?
- Is there a general problem with alpha channel? Can you do simple things like "-channel A -multiply 50%" etc?
Sorry I don't have a magic solution.
I have a general-purpose regression test suite, but no time to run it tonight.
You probably have plenty of bug-tracking experience but I'd suggest:
- You are using a pre-compiled version? If not, perhaps your build was bad.
- Are you using the DLL version? If so, are you sure it isn't using the wrong DLLs?
- Try a different format for moon_mask, eg png or tiff instead of gif.
- If this fails for all file types, do any of the other compose methods fail?
- Is there a general problem with alpha channel? Can you do simple things like "-channel A -multiply 50%" etc?
Sorry I don't have a magic solution.
I have a general-purpose regression test suite, but no time to run it tonight.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: IM copy_opacity example seems to fail
I just tested textcleaner on the congress.jpg example and it seems to work fine, thought the blue is a bit more saturated than it used to be. However, the copy_opacity seems to work fine.
Can you provide a link to your image and the exact script command you used that made the script fail?
Can you provide a link to your image and the exact script command you used that made the script fail?
Re: IM copy_opacity example seems to fail
To Fred:
My first post contains the two scripts I used which are copies from the imagemagick
examples. The IM example actually has `CopyOpacity', no hyphen. But I tried both
with the same lack of result.
It is strange that copy_opacity does seem to work in your textcleaner.
I used it a couple of days previously - I had better check that, maybe it does not
need to work for the text cleaning I was using it for.
My first post contains the two scripts I used which are copies from the imagemagick
examples. The IM example actually has `CopyOpacity', no hyphen. But I tried both
with the same lack of result.
It is strange that copy_opacity does seem to work in your textcleaner.
I used it a couple of days previously - I had better check that, maybe it does not
need to work for the text cleaning I was using it for.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: IM copy_opacity example seems to fail
For any of the compose operations that have an underscore, you can remove the underscore and concatenate the two words. They are equivalent.
The following works fine for me on IM 6.8.7.5 Q16
Perhaps it has to do with your Korn shell on Windows?
try putting quotes about "white-dodgerblue" --- it may not make a difference, but worth trying. Try double quotes rather than single quotes everwhere.
The following works fine for me on IM 6.8.7.5 Q16
Code: Select all
convert -size 70x70 xc:black -fill white -draw 'circle 35,35 35,5' \
-fill black -draw 'circle 28,30 35,5' moon_mask.gif
convert -size 70x70 plasma:white-dodgerblue moon_mask.gif \
-alpha Off -compose CopyOpacity -composite moon_gradient.png
try putting quotes about "white-dodgerblue" --- it may not make a difference, but worth trying. Try double quotes rather than single quotes everwhere.
Re: IM copy_opacity example seems to fail
There seems to be a serious gap in my knowledge of transparency.
Repeating the example script in the IM V6 Composting examples:
convert -size 70x70 xc:black -fill white -draw 'circle 35,35 35,5' \
-fill black -draw 'circle 28,30 35,5' moon_mask.gif
convert -size 70x70 plasma:white-dodgerblue moon_mask.gif \
-alpha Off -compose CopyOpacity -composite moon_gradient.png
The example page displays a crescent moon coloured by bluish plasma,
with the background transparent.
Running the above script on a recent version of IM and looking at the
result with a GUI (Paint Shop Pro 7 - grey background screen), the entire image
displays as bluish plasma - no moon.
Performing a similar masking operation within the GUI, produces the crescent
moon in bluish plasma and the background is transparent.
BUT, opening the original moon_gradient.png with another GUI, IrfanView
(black background screen), the image is the crescent moon in bluish plasma
and the background is transparent (at least, it is black on the black screen).
That is, apparently correct all along.
What am I missing here?
Regards
Repeating the example script in the IM V6 Composting examples:
convert -size 70x70 xc:black -fill white -draw 'circle 35,35 35,5' \
-fill black -draw 'circle 28,30 35,5' moon_mask.gif
convert -size 70x70 plasma:white-dodgerblue moon_mask.gif \
-alpha Off -compose CopyOpacity -composite moon_gradient.png
The example page displays a crescent moon coloured by bluish plasma,
with the background transparent.
Running the above script on a recent version of IM and looking at the
result with a GUI (Paint Shop Pro 7 - grey background screen), the entire image
displays as bluish plasma - no moon.
Performing a similar masking operation within the GUI, produces the crescent
moon in bluish plasma and the background is transparent.
BUT, opening the original moon_gradient.png with another GUI, IrfanView
(black background screen), the image is the crescent moon in bluish plasma
and the background is transparent (at least, it is black on the black screen).
That is, apparently correct all along.
What am I missing here?
Regards
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: IM copy_opacity example seems to fail
"-alpha Off -compose CopyOpacity -composite" should result in the greyness of the second image being copied into the alpha channel of the first, leaving the RGB of the first unchanged. If you look at the pixel values of the transparent image (using IM "txt:" format, or Gimp's eyedropper, or similar), that's what you should see.
Image viewers show fully transparent pixels in a number of ways. They might:
- show white (eg Windows Photo Viewer)
- show grey chequerboard (eg Gimp)
- show black
- ignore the alpha channel and show the colour represented by the pixel values.
Sadly, only experience with a viewer tells us what it will do.
Image viewers show fully transparent pixels in a number of ways. They might:
- show white (eg Windows Photo Viewer)
- show grey chequerboard (eg Gimp)
- show black
- ignore the alpha channel and show the colour represented by the pixel values.
Sadly, only experience with a viewer tells us what it will do.
snibgo's IM pages: im.snibgo.com
Re: IM copy_opacity example seems to fail - Solved
The GUI being used to check the image was PSP-7. A vague recollection of a GUI upgrade being
provided 10 or more years ago, stimulated an extensive search through disks. There was in fact
an upgrade and it had not been applied to the GUI on the PC being used. Upon performing the
upgrade, the image displayed was a bluish plasma moon against a transparent background - just as
in the IM example.
It would seem that recovering from disk failures/replacements on the PC had resulted in a
loss of `coporate memory' of the need to upgrade a re-installed GUI on a replacement disk.
Sorry for wasting your time snibgo and Fred.
Regards
provided 10 or more years ago, stimulated an extensive search through disks. There was in fact
an upgrade and it had not been applied to the GUI on the PC being used. Upon performing the
upgrade, the image displayed was a bluish plasma moon against a transparent background - just as
in the IM example.
It would seem that recovering from disk failures/replacements on the PC had resulted in a
loss of `coporate memory' of the need to upgrade a re-installed GUI on a replacement disk.
Sorry for wasting your time snibgo and Fred.
Regards