PDF to JPG clipping path

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?".
Post Reply
spittman
Posts: 4
Joined: 2019-09-24T05:52:49-07:00
Authentication code: 1152

PDF to JPG clipping path

Post by spittman »

Hi all,
Is there a way to convert PDF files to JPG files with clipping paths using ImageMagick?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PDF to JPG clipping path

Post by fmw42 »

What is your IM version and platform? Post your PDF file so we can examine it.
spittman
Posts: 4
Joined: 2019-09-24T05:52:49-07:00
Authentication code: 1152

Re: PDF to JPG clipping path

Post by spittman »

ImageMagick 6.9.10-42 running on Red Hat 7.4

https://gofile.io/?c=JTWaw6
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PDF to JPG clipping path

Post 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
spittman
Posts: 4
Joined: 2019-09-24T05:52:49-07:00
Authentication code: 1152

Re: PDF to JPG clipping path

Post by spittman »

Thank you very much for the detailed clarification :)
spittman
Posts: 4
Joined: 2019-09-24T05:52:49-07:00
Authentication code: 1152

Re: PDF to JPG clipping path

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

Re: PDF to JPG clipping path

Post 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.
snibgo's IM pages: im.snibgo.com
Post Reply