ImageMagick 6.7.5-6
The following commands generate text on green background, instead of the desired black background:
convert -quiet -colorspace RGB -type truecolor -alpha on -size 720!x480! xc:"#000000FF" temp.png
convert -quiet -colorspace RGB -type truecolor -alpha on temp.png -fill "#FFFFFFFF" -stroke "#FFFFFFFF" -pointsize 32 -draw "text 78 44 'Text'" 00000001.png
with just a slight adjustment it works almost as desired:
convert -quiet -colorspace RGB -type truecolor -alpha on -size 720!x480! xc:"#000001FF" temp.png
convert -quiet -colorspace RGB -type truecolor -alpha on temp.png -fill "#FFFFFFFF" -stroke "#FFFFFFFF" -pointsize 32 -draw "text 78 44 'Text'" 00000001.png
and:
convert -quiet -colorspace RGB -type truecolor -alpha on -size 720!x480! xc:"#000000FF" temp.jpg
convert -quiet -colorspace RGB -type truecolor -alpha on temp.jpg -fill "#FFFFFFFF" -stroke "#FFFFFFFF" -pointsize 32 -draw "text 78 44 'Text'" 00000001.png
also works OK.
Seems like in the first example a YUV colorspace is being used incorrectly.
Bug generating text on black frames
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Bug generating text on black frames
Your version of IM is old, and at that time it was confused about RGB and sRGB. I suggest you upgrade, to at least 6.7.9.
The syntax for convert is:
Putting the options first might happen to work, but I suggest you don't.
JPG files can't store transparency. PNG files can.This shouldn't matter, as you are not using transparency.
The following seems to do what you want:
Or, perhaps a little clearer:
The syntax for convert is:
Code: Select all
convert infile {options that change the image} outfile
JPG files can't store transparency. PNG files can.This shouldn't matter, as you are not using transparency.
The following seems to do what you want:
Code: Select all
convert -quiet -size 720x480 xc:"#000000FF" temp.png
convert -quiet temp.png -fill "#FFFFFFFF" -stroke "#FFFFFFFF" -pointsize 32 -draw "text 78 44 'Text'" 00000001.png
Code: Select all
convert -quiet -size 720x480 xc:Black temp.png
convert -quiet temp.png -fill White -stroke White -pointsize 32 -draw "text 78 44 'Text'" 00000001.png
snibgo's IM pages: im.snibgo.com
Re: Bug generating text on black frames
Thanks for the prompt reply, and glad to learn it has been fixed.
I tested with fedora 17, so I will check for updates to the imagemagick package.
Regards.
I tested with fedora 17, so I will check for updates to the imagemagick package.
Regards.
Re: Bug generating text on black frames
BTW, the "convert -quiet -colorspace RGB -type truecolor [-alpha on]" is autogenerated by my code. I need a generic command which ensures (as much as possible) that the output image is in the RGB24 (for .jpg) or RGBA32 (for .png) colorspace. Due to current programatic limitations this has to come at the start of the command. I realise it is not really correct, but the reported bug is the only case I have come across where this fails. Certainly in the first command there is only an output image, so the options should be applied to it.
If you have a better suggestion which would not add complication to the code then I would be interested to know it.
If you have a better suggestion which would not add complication to the code then I would be interested to know it.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Bug generating text on black frames
We are told that IM V7 will not process commands given in the wrong order.
In current IM versions (since about 6.7.9), "-colorspace RGB" will change the pixel values from the current colourspace (presumed sRGB) to RGB. This will change the colours in your image, making them darker if the source is sRGB. It has no effect on the output file format (eg indexed, or number of channels).
As this image is almost entirely black and white, the conversion to RGB will have little effect. (It would be visible only in the anti-aliased edges of the text). A rule of thumb: don't change an image's colorspace unless you really want to.
"-alpha on" won't guarantee the output PNG contains an alpha channel. Prefixing the filename with "PNG32:" does.
In current IM versions (since about 6.7.9), "-colorspace RGB" will change the pixel values from the current colourspace (presumed sRGB) to RGB. This will change the colours in your image, making them darker if the source is sRGB. It has no effect on the output file format (eg indexed, or number of channels).
As this image is almost entirely black and white, the conversion to RGB will have little effect. (It would be visible only in the anti-aliased edges of the text). A rule of thumb: don't change an image's colorspace unless you really want to.
"-alpha on" won't guarantee the output PNG contains an alpha channel. Prefixing the filename with "PNG32:" does.
snibgo's IM pages: im.snibgo.com
Re: Bug generating text on black frames
Thanks for that tip !