SOLVED - IM6 to IM7: now my images are grey?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
teracow
Posts: 21
Joined: 2013-04-30T02:55:12-07:00
Authentication code: 6789
Location: Brisbane, Australia

SOLVED - IM6 to IM7: now my images are grey?

Post by teracow »

Hey guys, haven't dropped by in a while. :)

ImageMagick has been working flawlessly in the googliser BASH script for the last couple of years, and I'm sure the only reason for the trouble now is due to my ignorance of the upgrades that came with IM7.

I only recently found that 'brew' (installed into macOS) now installs IM7 instead of IM6, which has created a problem when rendering a composite image with my old command strings. For testing, I've created an Ubuntu 19.10 VM with IM7 manually installed - it produces the same problem image.

In Debian 10.2 - works fine:

Code: Select all

$ convert -version
Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
Let's build a couple of images, then composite them:

Code: Select all

convert -size 300x300 radial-gradient:WhiteSmoke-gray10 background.png
Image

Code: Select all

convert -size x100 -font Century-Schoolbook-L-Bold-Italic -background none -fill goldenrod1 label:"\ title " -flatten title.png
Image

Code: Select all

convert background.png title.png -gravity center -composite combined.png
Image
... and this is the result I'm looking for.

Now, in an Ubuntu 19.10 VM - not so much:

Code: Select all

$ magick -version
Version: ImageMagick 7.0.9-5 Q16 x86_64 2019-11-24 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC

Code: Select all

convert -size 300x300 radial-gradient:WhiteSmoke-gray10 background.png
Image

Code: Select all

convert -size x100 -font Century-Schoolbook-L-Bold-Italic -background none -fill goldenrod1 label:"\ title " -flatten title.png
Image

Code: Select all

convert background.png title.png -gravity center -composite combined.png
Image
... and the colour is gone.

I'm almost positive this is due to my use of transparency via '-background none'.

Does anyone know how to fix this? Thank you. :)
Last edited by teracow on 2019-11-24T11:55:20-07:00, edited 1 time in total.

User avatar
GeeMack
Posts: 753
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: IM6 to IM7: now my images are grey?

Post by GeeMack »

teracow wrote:
2019-11-24T01:05:06-07:00
I'm almost positive this is due to my use of transparency via '-background none'.

Does anyone know how to fix this? Thank you.
When compositing images, the general behavior in more recent versions of IM is to apply the properties of the destination image to the finished result. In this case the destination is your grayscale gradient, so the result will be in the colorspace gray. Try adding "-colorspace sRGB" before the composite operation...

Code: Select all

convert background.png title.png -gravity center -colorspace sRGB -composite combined.png
That should force the output to be in the sRGB colorspace, and your text should be gold as you specified.

As a side note, you could do all those operations as a single command something like this...

Code: Select all

convert -size 300x300 radial-gradient:WhiteSmoke-gray10 -size x100 \
   -font Century-Schoolbook-L-Bold-Italic -fill goldenrod1 -background none \
   label:"\ title " -gravity center -colorspace sRGB -composite title.png

User avatar
teracow
Posts: 21
Joined: 2013-04-30T02:55:12-07:00
Authentication code: 6789
Location: Brisbane, Australia

Re: IM6 to IM7: now my images are grey?

Post by teracow »

GeeMack wrote:
2019-11-24T08:03:19-07:00
When compositing images, the general behavior in more recent versions of IM is to apply the properties of the destination image to the finished result. In this case the destination is your grayscale gradient, so the result will be in the colorspace gray. Try adding "-colorspace sRGB" before the composite operation...

Code: Select all

convert background.png title.png -gravity center -colorspace sRGB -composite combined.png
Yup, that's what I was missing. Thanks @GeeMack! :D

... and fixed.
GeeMack wrote:
2019-11-24T08:03:19-07:00
As a side note, you could do all those operations as a single command something like this...
Nice! :mrgreen:

Post Reply