convert command stopped working (partially)

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
ggking7
Posts: 21
Joined: 2010-11-15T13:19:04-07:00
Authentication code: 8675308

convert command stopped working (partially)

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert command stopped working (partially)

Post 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
ggking7
Posts: 21
Joined: 2010-11-15T13:19:04-07:00
Authentication code: 8675308

Re: convert command stopped working (partially)

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert command stopped working (partially)

Post 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?
ggking7
Posts: 21
Joined: 2010-11-15T13:19:04-07:00
Authentication code: 8675308

Re: convert command stopped working (partially)

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert command stopped working (partially)

Post 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.
ggking7
Posts: 21
Joined: 2010-11-15T13:19:04-07:00
Authentication code: 8675308

Re: convert command stopped working (partially)

Post by ggking7 »

Upgrading to 6.7.6.9 fixed it. Thank you!
Post Reply