Page 1 of 1

LevelColors in Perl Magick broken?

Posted: 2011-05-04T16:21:05-07:00
by jonathantrevor
Version: ImageMagick-6.6.9-6

The PerlMagick library appears to have a very mis-matched binding for the LevelColors call, or least differs from the online documentation:

Magick.xs: Line 525:

Code: Select all

    { "LevelColors", { {"invert", MagickBooleanOptions},
      {"black-point", RealReference}, {"white-point", RealReference},
      {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
This has TWO inverts in it, and takes a real reference as the black and white points - whereas the usage in the command line with +LevelColors takes a color/string, as does the Perl Magick documentation.

In addition: Line 10499

Code: Select all

        case 129:  /* LevelColors */
        {
          MagickPixelPacket
            black_point,
            white_point;

          (void) QueryMagickColor("#000000",&black_point,exception);
          (void) QueryMagickColor("#ffffff",&black_point,exception);
Assigns "#ffffff" to the black point (this seems wrong but perhaps its by design)

With this configuration I can't find a way to run level colors without getting this exception:

Code: Select all

$image->LevelColors('black-point' => "#ff0000", 'white-point' => '#ffffff');

Code: Select all

magick/color.c:2542: QueryMagickColorCompliance: Assertion `name != (const char *) ((void *)0)' failed.
I adjusted these in the XS to allow strings instead of reals and then the LevelColors succeeded - although the results didnt appear to actually work correctly (the example above didnt "redden" the black in a greyscale image, it only did the mid-tones)

Thanks
Jonathan

Re: LevelColors in Perl Magick broken?

Posted: 2011-05-12T13:52:44-07:00
by magick
Thanks for the bug report and analysis. We have a patch in ImageMagick 6.6.9-9 Beta available by sometime tomorrow to fix the problem.