Page 1 of 1

PDF to JPG clipping path

Posted: 2019-09-24T06:01:43-07:00
by spittman
Hi all,
Is there a way to convert PDF files to JPG files with clipping paths using ImageMagick?

Re: PDF to JPG clipping path

Posted: 2019-09-24T09:19:17-07:00
by fmw42
What is your IM version and platform? Post your PDF file so we can examine it.

Re: PDF to JPG clipping path

Posted: 2019-09-26T06:49:14-07:00
by spittman
ImageMagick 6.9.10-42 running on Red Hat 7.4

https://gofile.io/?c=JTWaw6

Re: PDF to JPG clipping path

Posted: 2019-09-26T09:48:14-07:00
by fmw42
Your pdf has no clip path (nor an 8bim profile to get it from). But the PDF does contain an image with a clip path. So you need to extract it from the PDF vector shell. Then you can combine them to make the background transparent. To do this you can use pdfimages tool. See https://manpages.debian.org/testing/pop ... .1.en.html. It is part of the poppler tools. See https://en.wikipedia.org/wiki/Pdfimages and https://poppler.freedesktop.org

Code: Select all

pdfimages -tiff example.pdf example
convert example-000.tif example-001.tif -alpha off -compose copy_opacity -composite example.png
Image

Re: PDF to JPG clipping path

Posted: 2019-09-27T03:52:06-07:00
by spittman
Thank you very much for the detailed clarification :)

Re: PDF to JPG clipping path

Posted: 2019-10-09T05:23:52-07:00
by spittman
Just one more thing. In the example commands you showed me it's taking out a TIFF file out of the PDF and converting to PNG with IM.
I tried running

Code: Select all

pdfimages -j example.pdf example
The output was 2 files:
* example-000.jpg
* example-001.ppm

but I was hoping I'd get the JPG file with a clipping path included.
Is there a way to combine those two into one JPG file with a clipping path using ImageMagick?

Re: PDF to JPG clipping path

Posted: 2019-10-09T05:45:21-07:00
by snibgo
spittman wrote:Is there a way to combine those two into one JPG file with a clipping path using ImageMagick?
No, IM can't write clipping paths. Gimp can.