Page 1 of 2
JPG with Clipping Path to PNG with transparency
Posted: 2010-02-19T07:17:30-07:00
by silver6523
What I want to do is trimming a JPG to its clipping path and setting everything outside the clipping path to transparency. The new file should be a PNG.
For example:
I have a picture with a bottle. The bottle is in the middle of the image an its edges does not touch the corner of the pictures. The bottle is outlined by a clipping path and now i want to create a new file with nothing more than this bottle. Now the bottle should touch the corner of the new picture.
I'm working with ImageMagick (Version 6.3.0) and tried this one: convert src.jpg -clip -trim dst.png
Re: JPG with Clipping Path to PNG with transparency
Posted: 2010-02-19T10:49:24-07:00
by fmw42
Post a link to your jpg image which has the clipping path in it.
Re: JPG with Clipping Path to PNG with transparency
Posted: 2010-02-24T02:47:10-07:00
by silver6523
Here is the JPG-File I want to clip to a transparent background:
http://rene.ateam.de/bild.JPG
Re: JPG with Clipping Path to PNG with transparency
Posted: 2010-02-24T03:16:04-07:00
by silver6523
btw.:
"convert bild.JPG -clip -background transparent test.png"
results in an file where the clipped picture is on a black background (instead of a transparent one)
Re: JPG with Clipping Path to PNG with transparency
Posted: 2010-02-24T04:54:36-07:00
by snibgo
This will do it:
/usr/bin/convert bild.JPG -alpha set -channel alpha -clip -negate temp.png
/usr/bin/convert temp.png -channel Alpha -negate c.png
Smarter folks than me will simplify it.
Edit: +trim +repage after the final -negate, if you want.
Re: JPG with Clipping Path to PNG with transparency
Posted: 2010-02-24T05:24:55-07:00
by silver6523
what i get is: unrecognized option `-alpha'.
Re: JPG with Clipping Path to PNG with transparency
Posted: 2010-02-24T05:29:58-07:00
by snibgo
It's fine on 6.4.5. Your version is very old; I suggest you upgrade it and try again.
Re: JPG with Clipping Path to PNG with transparency
Posted: 2010-07-20T14:52:27-07:00
by shellynne7
Thank you for the original post. It has been most helpful. I've been able to use that set of commands to successfully convert EPS files with clipping paths to transparent-background PNG files locally on two Macs (one running Snow Leopard, and one considerably older than that.) Both machines that work are using 6.6.2.7 and were built from source to include several other libraries. I then built IM on a linux box here, using the same version of those same libraries, and using IM 6.6.2.10. In those files, the transparency isn't working. When I open and get the details on the file created after the first step on the new (broken) machine, I'm getting:
Alpha:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
For the one that works, I'm getting:
Alpha:
min: 0 (0)
max: 255 (1)
mean: 70.1693 (0.275174)
Is there possibly an issue with 6.6.2.10 (or .8 / .9)? Or is there some other library I need to watch out for on this new box. I've listed the libraries I used for the IM builds below.
libpng-1.4.3
jpeg-8a
lcms-1.19
ghostscript-8.71
freetype-2.3.12
libwmf-0.2.8.4
tiff-3.9.4
Thanks in advance for any insights you might have!
Re: JPG with Clipping Path to PNG with transparency
Posted: 2010-07-20T15:43:24-07:00
by fmw42
on older versions of IM -matte is the same as -alpha set, as I recall,
see
http://www.imagemagick.org/Usage/basics/#alpha
Re: JPG with Clipping Path to PNG with transparency
Posted: 2010-07-21T08:28:27-07:00
by shellynne7
I'm not really on an older version (or that old, at least. The versions I'm on are only a couple of months old or less). The machine that is working fine using the original post's recommendation is 6.6.2-7, and the machine that isn't working is running 6.6.2-10. I'm doubting it's an issue with the commands working differently between the two versions. Rather, I suspect there is some sort of library that I already had installed on one machine but didn't have on the new machine. But I'm not sure what that could be, and I'm looking for ideas on whether there are any libraries that would affect alpha channel output.
My next step is to try to downgrade the non-working machine back to 6.6.2-7 to isolate whether that is the problem. As I mentioned, I highly doubt it is, but if there are no obvious libraries or other issues (mac osx vs. linux) anyone might suspect, then I'll go down that route to see for sure.
Thanks in advance!
Re: JPG with Clipping Path to PNG with transparency
Posted: 2010-07-21T09:11:28-07:00
by fmw42
silver6523 wrote:what i get is: unrecognized option `-alpha'.
What is the full command line that produces this error?
Re: JPG with Clipping Path to PNG with transparency
Posted: 2010-07-21T14:22:48-07:00
by Drarakel
silver6523 is not around anymore, Fred. (And probably his problem is already solved.)
@shellynne7:
I don't think that version 6.6.2-10 has an issue. But, yes, other things could be involved, especially with EPS files (Ghostscript).
Can you post the commandline that you were using and a link to your EPS file (and perhaps your output file)? That would make it easier for us. And what is the "original post" you're refering to? You don't mean 'convert src.jpg -clip -trim dst.png' (from the original post), do you?
Re: JPG with Clipping Path to PNG with transparency
Posted: 2010-07-21T16:28:04-07:00
by fmw42
silver6523 is not around anymore, Fred. (And probably his problem is already solved.)
Sorry, I had not realized that someone had tacked onto this post. You are on top of it, so I will bow out. Thanks.
Re: JPG with Clipping Path to PNG with transparency
Posted: 2010-07-21T22:53:45-07:00
by anthony
silver6523 wrote:what i get is: unrecognized option `-alpha'.
Use the older option
-matte instead then.
Re: JPG with Clipping Path to PNG with transparency
Posted: 2010-07-22T15:37:23-07:00
by shellynne7
Thanks for your response.
I'm using the following commands:
convert 1031517_A.eps -alpha set -channel alpha -clip -negate Temp1/1031517_A.eps.png;
convert Temp1/1031517_A.eps.png -channel Alpha -negate Temp2/1031517_A.eps.png;
I've attached the source file, as well. As I mentioned, it's working fine on the two macs I have set up, but on the linux box I set up, that file that ends up in the Temp1 folder in this command contains no alpha channel values when I run it through the linux set up, so, subsequently, the final image in the Temp2 folder does not have a transparent background. When I run it through the macs, the file in Temp1 has a black background with a grey knockout inside the clipping path, and the Temp2 output has the original contents from within the clipping path on a transparent background (the desired outcome).
Please let me know if there's anything else I can provide as to server set-up or if there are problems you see with the way I'm converting these files to get the desired results.
Source Image:
http://ackappdev.brandconstructionkit.c ... 1517_A.eps
Thanks so much for your time!