Page 1 of 1

convert command stopped working (partially)

Posted: 2012-05-06T09:37:18-07:00
by ggking7
I've been using the following command in a perl script for a long time:

system(qq{convert images/"$sku".jpg -resize "$width"x"$height" -alpha set -virtual-pixel transparent -channel A -blur 0x10 -level 50%,100% +channel -background white -flatten -quantize RGB -quality 85 /path/to/new/file/"$sku".jpg});

A couple weeks ago it stopped working correctly. I use Gentoo and I update my system a lot so I'm not sure what did it. The image it produces is now all white with sort of dithered black edges. The following command still works fine:

system(qq{convert images/"$sku".jpg -resize "$width"x"$height" -quantize RGB -quality 85 /path/to/new/file/"$sku".jpg});

Can anyone see what I'm doing wrong?

I would prefer to use PerlMagick but I couldn't figure out how to make it work with that API. Is PerlMagick still being developed?

Re: convert command stopped working (partially)

Posted: 2012-05-06T10:29:50-07:00
by fmw42
I am not sure this is the cause, but a few releases back alpha channel was changed from opacity to transparency. But that was with -separate. I don't think it changes in this case. But to be sure try adding -negate after -channel A

Re: convert command stopped working (partially)

Posted: 2012-05-07T00:28:11-07:00
by ggking7
Thanks, I tried the following:

system(qq{convert images/"$sku".jpg -resize "$width"x"$height" -alpha set -virtual-pixel transparent -channel A -negate -blur 0x10 -level 50%,100% +channel -background white -flatten -quantize RGB -quality 85 /path/to/new/file/"$sku".jpg});

but the result now looks the same as the second example in my original post, no soft edges at all.

Re: convert command stopped working (partially)

Posted: 2012-05-07T10:44:44-07:00
by fmw42
can you post a link to one input image and your exact parameters for your command and the output you are achieving so others can test.

and what version of IM you are using.

can you test in a terminal window without PHP?

Re: convert command stopped working (partially)

Posted: 2012-05-09T04:28:02-07:00
by ggking7
Here is an image:
http://oi45.tinypic.com/2ccwleo.jpg

Here is the image after running it through convert via the command line:
http://oi49.tinypic.com/votu12.jpg

Here is the convert command which used to only soften the edges of the image:

convert image.jpg -alpha set -virtual-pixel transparent -channel A -blur 0x10 -level 50%,100% +channel -background white -flatten -quantize RGB -quality 85 converted-image.jpg

If I add '-negate' after '-channel A', the image looks the same after conversion as it does before conversion.

I'm using imagemagick-6.7.6.4 on Gentoo. Do anyone know how to fix this? Do you get the same result?

Re: convert command stopped working (partially)

Posted: 2012-05-09T09:56:43-07:00
by fmw42
It works just fine for me on IM 6.7.6.9 Q16 Mac OSX Snow Leopard. I get your image with white border and rounded corners.

convert 2ccwleo.jpg -alpha set -virtual-pixel transparent \
-channel A -blur 0x10 -level 50%,100% +channel \
-background white -flatten -quantize RGB -quality 85 2ccwleo_proc.jpg

It may(?) be possible that this is related to the switch between sRGB and RGB that was in transition between IM 6.7.5.5 and 6.7.6.7.

In any case try upgrading to the current IM release.

Re: convert command stopped working (partially)

Posted: 2012-05-11T00:52:40-07:00
by ggking7
Upgrading to 6.7.6.9 fixed it. Thank you!