Convert section of PDF?

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?".
User avatar
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Convert section of PDF?

Post by GeeMack »

pctechtv wrote:I'm thinking there must be an option to leave off the last part with the output directory and tell ImageMagick just to create the jpeg in the original file's directory. If so how is this done? Thanks
You can set an output file name which is made from the input file name. Using the same example command I used above, and adding a variable with "-set filename:f", then naming the output file with that variable, we end up with a command like this...

Code: Select all

magick -density 300 mypdf.pdf[0] -set filename:f "%[d]/%[t]" ^
    -crop %[w]x%[fx:w/16*9]+0+0 +repage -resize %[fx:resolution.x*8.5]x "%[filename:f].jpg"
That will create your output JPG with the same name as your input PDF, but with the ".jpg" extension, and in the same directory as the input file. If there's any possibility your file name might have spaces or odd characters, make sure you use quote marks around the "%[d]/%[t]" variable and the "%[filename:f].jpg" at the end.

Read more about how you can use those IM built-in variables at this LINK. That's why they call it ImageMagick. :o
Posts: 22
Joined: 2016-10-09T19:47:59-07:00
Authentication code: 1151

Re: Convert section of PDF?

Post by pctechtv »

This really is helpful. Thank You!
Post Reply