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?
convert command stopped working (partially)
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert command stopped working (partially)
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)
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.
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert command stopped working (partially)
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?
and what version of IM you are using.
can you test in a terminal window without PHP?
Re: convert command stopped working (partially)
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?
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?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert command stopped working (partially)
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.
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)
Upgrading to 6.7.6.9 fixed it. Thank you!