Bug 24673

Summary: Using Imagemagick (convert) for replacing colors is broken (cauldron regression)
Product: Mageia Reporter: Juergen Harms <juergen.harms>
Component: RPM PackagesAssignee: All Packagers <pkg-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Normal CC: marja11, smelror
Version: Cauldron   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Source RPM: imagemagick-7.0.8.40-1.mga7.src.rpm CVE:
Status comment:
Attachments: target file for the demo imagemagick example
short demo programme for use with perl-Image-Magick

Description Juergen Harms 2019-04-15 22:51:19 CEST Comment hidden (obsolete)
Comment 1 Juergen Harms 2019-04-15 23:27:38 CEST
Sorry, I accidentally sent the report before I had finished drafting - starting fresh.

Description of problem:

Imagemagic allows to replace colors (for instance the background) in an image. As a consequence of one of the recent upgrades of imagemagick in cauldron, this feature does not work any more


Version-Release number of selected component (if applicable):

imagemagick 7.0.8.40-1

How reproducible:

always


Steps to Reproduce:

1. Run the following command-line
  convert <sourcefile> -fuzz 10% -fill <newcolour> -opaque <oldcolour> <destfile>

As an attachment, a short demo file "source.pnm" is provided, where the background is to be changed from white to red by the command

  convert source.pnm -fuzz 10% -fill red -opaque white dest.pnm

An old imagemagick (6.9.10.0-1.1) does this correctly, the present imagemagick in cauldron paints everything black - or does nothing if some other colour is specified as the target colour to be replaced.
Comment 2 Juergen Harms 2019-04-15 23:29:29 CEST
Created attachment 10939 [details]
target file for the demo imagemagick example
Comment 3 Juergen Harms 2019-04-16 19:16:18 CEST
Same problem with perl-Image-Magick-7.0.8.40-1, perl demo programme attached.

I am sorry to be so vague about the revision at which the regression occured. I now recreated a Mageia-7 Beta-1 system (imagemagick 7.0.8.15-1): the regression is already present on that system (and, as already said, not on Mageia-6 with  imagemagick 6.9.10.0-1.1).
Comment 4 Juergen Harms 2019-04-16 19:18:28 CEST
Created attachment 10942 [details]
short demo programme for use with perl-Image-Magick
Comment 5 Marja Van Waes 2019-04-17 07:37:26 CEST
Assigning to all packagers collectively, since there is no registered maintainer for this package.
Also CC'ing the de-facto maintainer.

CC: (none) => marja11, smelror

Comment 6 Marja Van Waes 2019-04-17 07:37:58 CEST
(In reply to Marja Van Waes from comment #5)
> Assigning to all packagers collectively, since there is no registered
> maintainer for this package.
> Also CC'ing the de-facto maintainer.

Now really assigning :-(

Assignee: bugsquad => pkg-bugs

Comment 7 Stig-Ørjan Smelror 2019-04-17 10:06:59 CEST
Hi,

I was able to reproduce with the sample image. I was also unable to reproduce with a more complex image. In my image, it worked as expected.

Would suggest you report this upstream.

https://github.com/ImageMagick/ImageMagick/issues


Cheers,
Stig
Comment 8 Juergen Harms 2019-04-17 17:21:45 CEST
Thanks for picking this up so rapidly.

> I was also unable to reproduce with a more complex image.

I am intreagued by the difference between the results with my simple demo image and your more complex image. Trying to clarify, I found one more fact:

All pnm images resulting from a scan with my hp multifunction printer (and my demo image is a small zone cut out of such a scan) reproduce the problem. My MFP printer is a HP LaserJet Pro MFP M225-M226, I use xsane for scanning. Is your image output from a scanner?

Since the problem is not present on Mageia 6, it is not due to the printer itself - but it could be due a problem in a recent update of cups or a printer driver - probably not because I dont have any other problem with scanned images produced with that device on cauldron (for instance gimp is perfectly happy with such scanned images).

So, the correct title of the bug report should be:

Imagemagick fails to correctly replace colors in images scanned by an HP LaserJet Pro MFP M225-M226 multi-function device - which is too long.

What can I do to clarify to give this bug a chance to get resolved?
Comment 9 Stig-Ørjan Smelror 2019-04-17 18:36:31 CEST
Thanks Juergen.

My image came from, I guess, Photoshop. I ordered it from Fiverr.

I just tried with a screenshot and was able to fill the square with red, leaving the text black. I copied this text box only.

This likely means that there could be something with the packages you mentioned.

Also found this
https://answers.launchpad.net/hplip/+question/680239

% file source-gimp.png
source-gimp.png: PNG image data, 1625 x 83, 8-bit grayscale, non-interlaced

stig@dellirium:~/Downloads/image
% file source-gimp.pnm
source-gimp.pnm: Netpbm image data, size = 1625 x 83, rawbits, greymap

stig@dellirium:~/Downloads/image
% file source.pnm
source.pnm: Netpbm image data, size = 1625 x 83, rawbits, greymap

Still getting the same result. Just black.

Has the syntax for convert changed in regards to getting the desired result?

Cheers,
Stig
Comment 10 Juergen Harms 2019-04-17 20:20:13 CEST
> Has the syntax for convert changed in regards to getting the desired result?
Last question first: to my knowledge not - but I am an "imagemagick tourist"

> Still getting the same result. Just black.
That is, to me, normal: all your files have mode "graymap" or "grayscale" and can only represent white and black (and - according to evidence - imagemagick is not clever enough to recognize when the user introduces a colour and does not automatically change the mode to "rgb".

In my case, after the "aha" experience of this afternoon, I added to my "scanimage" call the option "--mode Color"; as a consequence, the files now support colours from the very beginning, and imagemagick is happy when I do "fill" with a colour.

You can manually change the mode of an existing image file with gimp (Unix would not be Unix if there would not be lots of better alternatives): open your file with gimp, use the  "Image" tab and the "mode" item - it offers a Radiobutton to set the mode. In case you are not familiar with gimp: gimp automatically opens the file as an .xcf file - to save it as - say - a pnm file, you must use the "Export" item of the file menu.

And, I do not think that there is a bug in one of the module we mentioned - just a change in the default settings of options - Unix ...

Cheers, Juergen
Comment 11 Stig-Ørjan Smelror 2019-04-19 14:33:45 CEST
Juergen,

can this bug be closed?

Cheers,
Stig
Comment 12 Juergen Harms 2019-04-19 22:51:45 CEST
Sure - I did not know the correct tag and not try
Comment 13 Stig-Ørjan Smelror 2019-04-20 00:01:08 CEST
OK. Thanks.

Closing.

Status: NEW => RESOLVED
Resolution: (none) => FIXED