I am in the process of creating several images, containing text and diagrams, using imagemagick and other tools.
At some point I realized that, even though the same instructions were being used in batch with little changes, the colors - defined very precisely by their hex value - change from image to image!
Here is an example (no input file needed) that gives reproduceably wrong (or at least unexpected) results on my machine (Ubuntu 14.04, ImageMagick 6.7.7-10 2017-07-31) [edited per fmw42's suggestion]
convert -size 66x46 -bordercolor "#a0a0a0" -border 2 xc:White -gravity Center -fill "#a0a0a0" -weight 700 -pointsize 24 -annotate 0 "0" a_1.png
convert -size 326x46 -bordercolor "#f0f0f0" -border 2 xc:White -gravity West -fill "#000000" -weight 700 -pointsize 14 -annotate +10+0 "4-Fluoroacetophenone" a_2.png
montage -colorspace sRGB a_1.png a_2.png -tile 2x1 -mode Concatenate -set colorspace sRGB a_3.png
convert -size 66x46 -bordercolor "#a0a0a0" -border 2 xc:White -gravity Center -fill "#a0a0a0" -weight 700 -pointsize 24 -annotate 0 "CN" b_1.png
convert -size 326x46 -bordercolor "#f0f0f0" -border 2 xc:White -gravity West -fill "#000000" -weight 700 -pointsize 14 -annotate +10+0 "trans-3-dimethylaminoacrylonitrile" b_2.png
montage -colorspace sRGB b_1.png b_2.png -tile 2x1 -mode Concatenate -set colorspace sRGB b_3.png
(I have left the original text variables, since I haven't been able to understand what triggers the change of color, and different rendered words give different results)
The 6 istructions above create these 6 images:
a_1.png a_2.png a_3.png
b_1.png b_2.png b_3.png
that appear like this:
As you can see, while a_1 and b_1 share the same color - and a_2 and b_2 as well - a_3 and b_3 (which are composite of a_1+a_2 and b_1+b_2) have different colors! Having added explicit specification of colorspace hasn't helped.
(This is not an artifact of having put the 6 pictures in a single file. The color difference is apparent in the separate files as well)
What is causing this? How can I get consistent colors in imagemagick? As I'm using visual color codes to convey information, I need palettes that I can rely on.
Edit: this does't happen (i.e. colors are consistent) with ImageMagick 6.8.9-9 Q16 x86_64 2017-07-31 that unfortunately isn't the version I have on my production machine.
I'm not removing the question as finding a solution within ImageMagick 6.7.7 would help. Or is it just a (known) bug and so the only solution is upgrading?