JPG with Clipping Path to PNG with transparency

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?".
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: JPG with Clipping Path to PNG with transparency

Post by snibgo »

On those 3 systems, what are the versions of IM and Ghostscript?
snibgo's IM pages: im.snibgo.com
shellynne7

Re: JPG with Clipping Path to PNG with transparency

Post by shellynne7 »

Mac 1 (working):
ImageMagick 6.6.2-7
Ghostscript 8.71

Mac 2 (working):
ImageMagick 6.6.2-7
Ghostscript 8.71

Linux (not working):
ImageMagick 6.6.2-10
Ghostscript 8.71

Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: JPG with Clipping Path to PNG with transparency

Post by snibgo »

Ah, I was hoping you might be on different Ghostscript versions, but that's not the problem.

If you run the first convert with "-verbose", you can get the actual Ghostscript command used. If you paste those here, we'll see what the difference is. (I'm not a Ghostscript expert, but someone else will be.)

For me, on Windows7, IM 6.6.3-0, the command does what I think you want, making a large transparent area against a black background:
D:\web\im>"%IMG%convert" -verbose 1031517_A.eps -alpha set -clip -channel alpha
-negate a.png
[ghostscript library] Files (x86)/gs/gs8.71/bin/gswin32c.exe" -q -dQUIET -dPARAN
OIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToP
ixels=0 -dGridFitTT=2 "-sDEVICE=pamcmyk32" -dTextAlphaBits=4 -dGraphicsAlphaBits
=4 "-r300x300" -g850x1200 "-sOutputFile=C:/Users/Alan/AppData/Local/Temp/magick
-UYBik-nh" "-fC:/Users/Alan/AppData/Local/Temp/magick-IL-Gntu8" "-fC:/Users/Alan
/AppData/Local/Temp/magick-iCo70L34"C:/Users/Alan/AppData/Local/Temp/magick-UYBi
k-nh PNM 850x1200 850x1200+0+0 8-bit ColorSeparation DirectClass 4.08MB 0.016u 0
:00.038
EPS:C:/Users/Alan/AppData/Local/Temp/magick-7H31Pixs=>C:/Users/Alan/AppData/Loca
l/Temp/magick-7H31Pixs EPS 849x1200=>850x1200 850x1200+0+0 16-bit ColorSeparatio
n DirectClass 4.08MB 0.000u 0:00.029
1031517_A.eps EPT 849x1200=>850x1200 850x1200+0+0 16-bit ColorSeparation DirectC
lass 4.08MB 0.000u 0:00.028
writing raw profile: type=8bim, length=17312
writing raw profile: type=exif, length=438
writing raw profile: type=iptc, length=40
writing raw profile: type=xmp, length=15976
1031517_A.eps=>a.png EPT 849x1200=>850x1200 850x1200+0+0 16-bit DirectClass 2.50
7MB 2.449u 0:02.302
snibgo's IM pages: im.snibgo.com
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: JPG with Clipping Path to PNG with transparency

Post by Drarakel »

Additionally - to narrow down the problem - you could test the clipping path alone with "convert 1031517_A.svg test.png":
1031517_A.svg (Link deleted)
Does that give you a silhouette of the image?
Last edited by Drarakel on 2010-09-25T23:35:28-07:00, edited 1 time in total.
shellynne7

Re: JPG with Clipping Path to PNG with transparency

Post by shellynne7 »

First the verbose logs

On the machine that is not delivering expected output:
convert -verbose 1031517_A.eps -alpha set -clip -channel alpha -negate a.png
"gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pam" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r300x300" -g850x1200 "-sOutputFile=/tmp/magick-XXwH7hLA" "-f/tmp/magick-XX8uvxJ2" "-f/tmp/magick-XXa23QHu"
/tmp/magick-XXwH7hLA PNM 850x1200 850x1200+0+0 8-bit ColorSeparation DirectClass 4.08MB 0.000u 0:00.010
EPS:/tmp/magick-XXOIicNW=>/tmp/magick-XXOIicNW EPS 849x1200=>850x1200 850x1200+0+0 8-bit ColorSeparation DirectClass 4.08MB 0.010u 0:00.000
1031517_A.eps EPT 849x1200=>850x1200 850x1200+0+0 8-bit ColorSeparation DirectClass 4.08MB 0.000u 0:00.000
writing raw profile: type=8bim, length=17312
writing raw profile: type=exif, length=438
writing raw profile: type=iptc, length=40
writing raw profile: type=xmp, length=15976
1031517_A.eps=>a.png EPT 849x1200=>850x1200 850x1200+0+0 8-bit DirectClass 1.02MB 0.770u 0:00.930


On the machine that is converting the file properly
convert -verbose 1031517_A.eps -alpha set -clip -channel alpha -negate a.png
"gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pam" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r300x300" -g850x1200 "-sOutputFile=/var/folders/S9/S9wxXkTy2RaaUk+BYvKSv++++TI/-Tmp-/magick-nnUm8iMq" "-f/var/folders/S9/S9wxXkTy2RaaUk+BYvKSv++++TI/-Tmp-/magick-cBk3S0kA" "-f/var/folders/S9/S9wxXkTy2RaaUk+BYvKSv++++TI/-Tmp-/magick-7dQP5HnE"
/var/folders/S9/S9wxXkTy2RaaUk+BYvKSv++++TI/-Tmp-/magick-nnUm8iMq PNM 850x1200 850x1200+0+0 8-bit ColorSeparation DirectClass 4.08MB 0.020u 0:00.070
EPS:/var/folders/S9/S9wxXkTy2RaaUk+BYvKSv++++TI/-Tmp-/magick-Kkm1e8ov=>/var/folders/S9/S9wxXkTy2RaaUk+BYvKSv++++TI/-Tmp-/magick-Kkm1e8ov EPS 849x1200=>850x1200 850x1200+0+0 8-bit ColorSeparation DirectClass 4.08MB 0.000u 0:00.000
1031517_A.eps EPT 849x1200=>850x1200 850x1200+0+0 8-bit ColorSeparation DirectClass 4.08MB 0.000u 0:00.000
writing raw profile: type=8bim, length=17312
writing raw profile: type=exif, length=438
writing raw profile: type=iptc, length=40
writing raw profile: type=xmp, length=15976
1031517_A.eps=>a.png EPT 849x1200=>850x1200 850x1200+0+0 8-bit DirectClass 1.016MB 1.060u 0:01.200


Thanks!
shellynne7

Re: JPG with Clipping Path to PNG with transparency

Post by shellynne7 »

I tried the clipping path alone on the provided .svg file.

On the mac (the one that has been working), I got a product silhouette on a white background. On the linux box (the one that hasn't been working), I got a product silhouette on a transparent background. I ran the exact same command for both.

Thanks!
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: JPG with Clipping Path to PNG with transparency

Post by Drarakel »

I'm wondering a bit about "-sDEVICE=pam" in your Ghostscript calls. My Ghostscript version (8.71, Windows) doesn't know this device. But you get an output from GS and it seems to be the same output on your different installations.. So, let's assume that the problem occurs after GS.

You're using Q8 versions of ImageMagick - right?
And the last test tells me that your linux box might use rsvg (for the clipping path) while your Macs use the internal SVG renderer. I don't think that this alone would be a problem in this case.. But maybe you can post the results of "convert -list format" for your different IM installations (only the two 'SVG' lines). On my system, I have:
SVG SVG rw+ Scalable Vector Graphics (XML 2.4.19)
SVGZ SVG rw+ Compressed Scalable Vector Graphics (XML 2.4.19)

Now I don't know much about the handling of SVG/clipping paths, so maybe someone else can give some suggestions.. Meanwhile, perhaps we can further narrow down the problem if we use this JPG for the next test:
http://i.imagehost.org/0491/1031517_A.jpg
As the last test did work (at least you got the silhouettes), this test should work, too:

Code: Select all

convert 1031517_A.jpg -fill blue -clip -draw "color 0,0 reset" test.jpg
This should make the interior of the clipping path blue (only the interior!). Is this successful on your linux box?
shellynne7

Re: JPG with Clipping Path to PNG with transparency

Post by shellynne7 »

I do see some differences with the svg support.

On the working machines, the SVG info:
SVG SVG rw+ Scalable Vector Graphics (XML 2.7.3)
SVGZ SVG rw+ Compressed Scalable Vector Graphics (XML 2.7.3)

SVG SVG rw+ Scalable Vector Graphics (XML 2.6.16)
SVGZ SVG rw+ Compressed Scalable Vector Graphics (XML 2.6.16)


On the non-working machine, the SVG info:
SVG SVG -w+ Scalable Vector Graphics
SVGZ SVG -w+ Compressed Scalable Vector Graphics


I'll run the jpg test now.
shellynne7

Re: JPG with Clipping Path to PNG with transparency

Post by shellynne7 »

In the jpg test, neither the working machine nor the non-working machine created a silhouette. Both PNG files looked exactly the same as the original jpg file.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: JPG with Clipping Path to PNG with transparency

Post by Drarakel »

shellynne7 wrote:In the jpg test, neither the working machine nor the non-working machine created a silhouette.
And there wasn't even an error message? Probably you have to replace the quotes on your Mac/Linux systems (I'm using Windows), so try this instead:
convert 1031517_A.jpg -fill blue -clip -draw 'color 0,0 reset' test.jpg

shellynne7 wrote:On the non-working machine, the SVG info:
SVG SVG -w+ Scalable Vector Graphics
SVGZ SVG -w+ Compressed Scalable Vector Graphics
Seems that the XML delegate is missing.
Can you post the output of "convert -list configure" from your Linux machine?
If it's indeed missing, you should try to install the latest libxml2 and then reinstall the latest ImageMagick..
shellynne7

Re: JPG with Clipping Path to PNG with transparency

Post by shellynne7 »

CC gcc -std=gnu99 -std=gnu99
CFLAGS -g -O2 -Wall -pthread
CONFIGURE ./configure '--disable-static' '--with-modules' '--without-perl' '--without-magick-plus-plus' '--with-quantum-depth=8' '--disable-openmp' '--with-gs-font-dir=/usr/local/share/ghostscript/fonts'
COPYRIGHT Copyright (C) 1999-2010 ImageMagick Studio LLC
CPPFLAGS -I/usr/local/include/ImageMagick
CXX g++
CXXFLAGS -g -O2 -pthread
DEFS -DHAVE_CONFIG_H
DELEGATES freetype jpeg jng lcms png tiff wmf zlib
DISTCHECK_CONFIG_FLAGS --disable-deprecated --with-umem=no --with-autotrace=no --with-fontconfig=no --with-gslib=no --with-fontpath= --with-gs-font-dir=/usr/local/share/ghostscript/fonts --with-rsvg=no --with-xml=no --with-perl=no
EXEC-PREFIX /usr/local
HOST x86_64-unknown-linux-gnu
LDFLAGS -L/usr/local/lib
LIB_VERSION 0x662
LIB_VERSION_NUMBER 6,6,2,10
LIBS -lMagickCore -llcms -ltiff -lfreetype -ljpeg -lz -lm -lpthread
NAME ImageMagick
PCFLAGS
PREFIX /usr/local
QuantumDepth 8
RELEASE_DATE 2010-07-01
VERSION 6.6.2
WEBSITE http://www.imagemagick.org

Path: [built-in]

Name Value
-------------------------------------------------------------------------------
NAME ImageMagick
shellynne7

Re: JPG with Clipping Path to PNG with transparency

Post by shellynne7 »

I reinstalled libxml2, and then reinstalled ImageMagick, and I'm still getting this:

SVG SVG -w+ Scalable Vector Graphics
SVGZ SVG -w+ Compressed Scalable Vector Graphics

Is there some variable I need to set during compilation to get it to "take"?

To install libxml2, I did:
sudo ./configure --prefix=/usr/local/src/libxml2-2.7.7
sudo make
sudo make install

And for ImageMagick, I did:
#!/bin/bash
# Install ImageMagick on Snow Leopard (10.6)
# Reported to work also on Leopard (10.5)
#
# Created by Claudio Poli (http://www.icoretech.org)

# Configuration.
# ImageMagick configure arguments.
IMAGEMAGICK_ARGUMENTS="--disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --disable-openmp"
# Installation path.
CONFIGURE_PREFIX=/usr/local/src # no trailing slash.
# GhostScript font path.
CONFIGURE_GS_FONT=$CONFIGURE_PREFIX/share/ghostscript


# ImageMagick.
# Software suite to create, edit, and compose bitmap images.
cd ImageMagick-6.6.3-0
export CPPFLAGS=-I$CONFIGURE_PREFIX/include
export LDFLAGS=-L$CONFIGURE_PREFIX/lib
./configure --prefix=$CONFIGURE_PREFIX $IMAGEMAGICK_ARGUMENTS --with-gs-font-dir=$CONFIGURE_GS_FONT/fonts
make
sudo make install
cd ..
shellynne7

Re: JPG with Clipping Path to PNG with transparency

Post by shellynne7 »

We found the issue in compilation (a flag indicating XML support as no). Once we made that modification, the system is working as needed. Thanks so much for your help in determining what was going wrong and which delegate we needed to find / activate! :D
Post Reply