Regression using last version(s) of ImageMagick

Steve Allewell steve.allewell at gmail.com
Sat Oct 13 16:17:42 BST 2018


On 12/10/2018 20:42, Sean Enck wrote:
> On 2018-10-08, Sean Enck wrote:
>> It appears importing an image has regressed (no longer works) against 
>> kxstitch 2.1.1 when using the latest (well archlinux latest) versions of 
>> image/libmagick. The current (not working version) in arch:
>>> imagemagick-7.0.8.12-1-x86_64.pkg.tar.xz
>>> libmagick-7.0.8.12-1-x86_64.pkg.tar.xz
>>
>> I downgraded my versions to verify and import worked (no crash):
>>> imagemagick-7.0.7.13-1-x86_64.pkg.tar.xz
>>> libmagick-7.0.7.13-1-x86_64.pkg.tar.xz
>>
>> The steps are:
>> 1. open kxstitch
>> 2. go to import image
>> 3. select an image (any image, I haven't seen it work)
>> 4. doesn't matter if you do anything before hitting "OK" when the image 
>> would go to the normal grid
>> 5. full crash, can provide a trace if there is anything special in kxstitch 
>> or any specific tracing method is preferred.
>>
>> Thanks for any help/insight,
>> --Sean
> 
> I was able to do some digging and found the issue started around ImageMagick 
> 7.0.7.24 (works) -> 7.0.7.25 (broken). I traced it to the FlossScheme.cpp 
> color matching where nullptr was being returned and I patched this in 
> Arch using the referenced patch below.
> 
> https://aur.archlinux.org/cgit/aur.git/plain/0001-Change-nearest-color-lookup-logic-for-finding-floss-.patch?h=kxstitch
> 
Hi Sean

Apologies for not getting back to you earlier.  I noticed you sent a
message to the list on the 8th, but it doesn't look like I got a copy of it.

I have version 7.0.8 of ImageMagick too and confirm the bug.

I had a look at the patch and it does the job, although it does not
require float for near and closest; abs and QColor red, green, blue
functions all return int.

I did a little rewrite which works for me, please check it for yourself:
-------------------------------------------------------------------------------
Floss *FlossScheme::find(const QColor &color) const
{
    QListIterator<Floss *> flossIterator(m_flosses);

    Floss *matched = nullptr;
    int closest = 100;

    while (flossIterator.hasNext()) {
        Floss *floss = flossIterator.next();
        QColor c = floss->color();

	// the color mapping may not be perfect so search for a near match.
        int distance = abs(color.red()-c.red()) +
abs(color.green()-c.green()) + abs(color.blue()-c.blue());

        if (distance < closest) {
            matched = floss;
            closest = distance;
        }
    }

    return matched;
}
-----------------------------------------------------------------------------

Do you want to commit the change?

I will have a look to see what changed in ImageMagic between those two
versions and see if there are any improvements to make.

Regards

Steve



More information about the KXStitch mailing list