How to clip?
-
- Posts: 18
- Joined: 2006-12-18T14:41:21-07:00
How to clip?
Hi,
I have several images with clipping paths (originating from Photoshop CS2; JPG, also tried TIFF and PSD; CMYK) and I'm trying to figure out, how to remove everything outside of the clipping path.
From the docs, I would have expected that e.g.
convert src.jpg -clip -trim dest.jpg
would do the trick, but this seems to do nothing (also no errors reported).
I also tried the example from the docs with
convert -clip -negate src.jpg dest.jpg
but this also does nothing.
Played around with -clip-mask and -clip-path. But either with the same result or an error.
Using "identify -verbose src.jpg" I can verify, there's a clipping path in there. Also copy and pasted the svg data to a new file and verified the path with Illustrator. Looks OK.
Help please,
Timo
PS: Version 6.3.0-7 on MacOS X 10.4.8, installed via DarwinPorts/MacPorts
I have several images with clipping paths (originating from Photoshop CS2; JPG, also tried TIFF and PSD; CMYK) and I'm trying to figure out, how to remove everything outside of the clipping path.
From the docs, I would have expected that e.g.
convert src.jpg -clip -trim dest.jpg
would do the trick, but this seems to do nothing (also no errors reported).
I also tried the example from the docs with
convert -clip -negate src.jpg dest.jpg
but this also does nothing.
Played around with -clip-mask and -clip-path. But either with the same result or an error.
Using "identify -verbose src.jpg" I can verify, there's a clipping path in there. Also copy and pasted the svg data to a new file and verified the path with Illustrator. Looks OK.
Help please,
Timo
PS: Version 6.3.0-7 on MacOS X 10.4.8, installed via DarwinPorts/MacPorts
-
- Posts: 18
- Joined: 2006-12-18T14:41:21-07:00
Thanks for your help, I've built 6.3.1-2 with the same settings and libs as 6.3.0. No change related to the clipping stuff for me.
Also tried the latest Windows binary on a different machine with the same results. Are the windows binaries compiled with support for XML?
One thing to note: My previous 6.3.0 build would often complain about "no clip path defined" for TIFFs, while I didn't get errors for JPGs. With 6.3.1 it's exactly the other way around. In this regard, the Windows binaries from imagemagick.org and my self-compiled 6.3.1-2 for MacOS X behave the same.
I'll prepare a sample image and post the URL.
Timo
Also tried the latest Windows binary on a different machine with the same results. Are the windows binaries compiled with support for XML?
One thing to note: My previous 6.3.0 build would often complain about "no clip path defined" for TIFFs, while I didn't get errors for JPGs. With 6.3.1 it's exactly the other way around. In this regard, the Windows binaries from imagemagick.org and my self-compiled 6.3.1-2 for MacOS X behave the same.
I'll prepare a sample image and post the URL.
Timo
-
- Posts: 18
- Joined: 2006-12-18T14:41:21-07:00
Here are links to two simple images which demonstrate my problem:
http://web.dd-com.de/download/IM/cliptest01.tif
http://web.dd-com.de/download/IM/cliptest01.jpg
The upper rectangle is surrounded by a clipping path, so I'd expect to see something when doing a "convert -clip -negate foo bar".
Here's the output I get for 6.3.0:
[mbp:~/Desktop] th% convert -clip -negate cliptest01.jpg jpg630.jpg
[mbp:~/Desktop] th% convert -clip -negate cliptest01.tif tif630.jpg
convert: no clip path defined `cliptest01.tif': Bad file descriptor.
Here's the output I get for 6.3.1:
[mbp:~/Desktop] th% convert -clip -negate cliptest01.jpg jpg631.jpg
convert: no clip path defined `cliptest01.jpg': No such file or directory.
[mbp:~/Desktop] th% convert -clip -negate cliptest01.tif tif631.jpg
Links for the generated files:
http://web.dd-com.de/download/IM/jpg630.jpg
http://web.dd-com.de/download/IM/jpg631.jpg
http://web.dd-com.de/download/IM/tif630.jpg
http://web.dd-com.de/download/IM/tif631.jpg
Timo
http://web.dd-com.de/download/IM/cliptest01.tif
http://web.dd-com.de/download/IM/cliptest01.jpg
The upper rectangle is surrounded by a clipping path, so I'd expect to see something when doing a "convert -clip -negate foo bar".
Here's the output I get for 6.3.0:
[mbp:~/Desktop] th% convert -clip -negate cliptest01.jpg jpg630.jpg
[mbp:~/Desktop] th% convert -clip -negate cliptest01.tif tif630.jpg
convert: no clip path defined `cliptest01.tif': Bad file descriptor.
Here's the output I get for 6.3.1:
[mbp:~/Desktop] th% convert -clip -negate cliptest01.jpg jpg631.jpg
convert: no clip path defined `cliptest01.jpg': No such file or directory.
[mbp:~/Desktop] th% convert -clip -negate cliptest01.tif tif631.jpg
Links for the generated files:
http://web.dd-com.de/download/IM/jpg630.jpg
http://web.dd-com.de/download/IM/jpg631.jpg
http://web.dd-com.de/download/IM/tif630.jpg
http://web.dd-com.de/download/IM/tif631.jpg
Timo
With 6.3.1-2 we get this clipping path:
- <?xml version="1.0" encoding="iso-8859-1"?>
<svg width="1000" height="2000">
<g>
<path style="fill:#00000000;stroke:#00000000;stroke-width:0;stroke-antialiasing:false" d="
M 71.8563,77.961
L 949.102,77.961
L 949.102,1031.48
L 59.8803,1031.48
"/>
</g>
</svg>
- convert cliptest01.tif -clip -negate tif631.jpg
-
- Posts: 18
- Joined: 2006-12-18T14:41:21-07:00
Hi,
thanks for the quick reply.
This is the same I get (for the TIFF and 6.3.1-2).
Yes, this is what I would have expected, but here I get two white rectangles (I also tried with the different order of the options).
I just cross-checked again on Windows with the binary available from the home page. Same (wrong) result as with my self-compiled one.
Any hint, where I could start searching for the problem?
I will try to setup a Linux in a virtual machine and see if I can reproduce your (correct) behaviour with the test files.
Thanks again for your help,
Timo
thanks for the quick reply.
magick wrote: With 6.3.1-2 we get this clipping path:
...
This is the same I get (for the TIFF and 6.3.1-2).
magick wrote: and with this command:We get a white rectangle on top surrounded by a black border and a black rectangle on bottom as we think is expected.
- convert cliptest01.tif -clip -negate tif631.jpg
Yes, this is what I would have expected, but here I get two white rectangles (I also tried with the different order of the options).
I just cross-checked again on Windows with the binary available from the home page. Same (wrong) result as with my self-compiled one.
Any hint, where I could start searching for the problem?
I will try to setup a Linux in a virtual machine and see if I can reproduce your (correct) behaviour with the test files.
Thanks again for your help,
Timo
-
- Posts: 18
- Joined: 2006-12-18T14:41:21-07:00
Update:
I installed Fedora Core as a VM in Parallels and installed the Linux RPM. There, the
convert in -clip -negate out
works indeed. So it works OK on linux, but not on MacOS X and Windows... Any ideas how to continue from here?
The Linux version also cannot find the clipping path in the JPG like the other 6.3.1-2 versions I tested. This was working with the 6.3.0 version (on OSX) I was using earlier today, but that one failed on TIFFs.
One more question, please: How can I tell convert, to remove/whiten everything outside of the clipping path?
Thanks,
Timo
I installed Fedora Core as a VM in Parallels and installed the Linux RPM. There, the
convert in -clip -negate out
works indeed. So it works OK on linux, but not on MacOS X and Windows... Any ideas how to continue from here?
The Linux version also cannot find the clipping path in the JPG like the other 6.3.1-2 versions I tested. This was working with the 6.3.0 version (on OSX) I was using earlier today, but that one failed on TIFFs.
One more question, please: How can I tell convert, to remove/whiten everything outside of the clipping path?
Thanks,
Timo
-
- Posts: 18
- Joined: 2006-12-18T14:41:21-07:00
magick wrote: Use +clippath #1 to apply an operator to the image outside the clipping path.
Mh, can't get it going... What's wrong?
- [th@localhost ~]$ uname -a
Linux localhost.localdomain 2.6.18-1.2798.fc6 #1 SMP Mon Oct 16 14:37:32 EDT 2006 i686 i686 i386 GNU/Linux
[th@localhost ~]$ convert -version
Version: ImageMagick 6.3.1 12/15/06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2007 ImageMagick Studio LLC
[th@localhost imtest]$ convert cliptest01.tif -clip -negate out.jpg
# OK
[th@localhost imtest]$ convert cliptest01.tif -clip +clip-path '#1' -negate out.jpg
convert: missing an image filename `out.jpg'.
[th@localhost imtest]$ convert cliptest01.tif -clip +clip-path '#1' out.jpg
convert: missing an image filename `out.jpg'.
[th@localhost imtest]$ convert cliptest01.tif +clip-path '#1' out.jpg
convert: missing an image filename `out.jpg'.
-
- Posts: 18
- Joined: 2006-12-18T14:41:21-07:00
Tobbe wrote: Did you find any solution to this?
I have IM 6.3.1 on Windows XP and can't get any clipping to work.
No, I didn't find a solution. I'm still interested in finding one, though.
Currently, my workaround is quite complicated: Transfer the file via SFTP to some other server, which is running some prepress OPI server, run some commands to do the clipping via SSH and transfer back the result via SFTP.
I would love to replace that with ImageMagick...
Timo