Convert PDF to JPG with minimum side length

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
fffranz
Posts: 8
Joined: 2016-10-16T03:24:31-07:00
Authentication code: 1151

Convert PDF to JPG with minimum side length

Post by fffranz »

Hi,
thanks for that nice program.
Now I have an question: is ist possible to convert an PDF to an certain side length - wherein the other side changes proportionally.
Sometimes I have small PDF with VectorImages - now I want to convert them to jpg or gif with the smalest side 300 pix - the other side will change proportionally. It doesnt matter if the small side is vertically or horizontally. Untill now i could not find a way.
Thank you in advance for your advices.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert PDF to JPG with minimum side length

Post by snibgo »

Try this:

Code: Select all

-resize "300x300^"
snibgo's IM pages: im.snibgo.com
fffranz
Posts: 8
Joined: 2016-10-16T03:24:31-07:00
Authentication code: 1151

Re: Convert PDF to JPG with minimum side length

Post by fffranz »

Hi, the other side should resize porportionally - not in the same way. Like the PDF is 600 x 700 - the jpg should be 300 x 350 ...
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert PDF to JPG with minimum side length

Post by snibgo »

Did you try my suggestion? Didn't it work?
snibgo's IM pages: im.snibgo.com
fffranz
Posts: 8
Joined: 2016-10-16T03:24:31-07:00
Authentication code: 1151

Re: Convert PDF to JPG with minimum side length

Post by fffranz »

Sorry, I have the" ^ "overlooked and thought that does not work. But: I tried it - and it works - GREAT - there is only one problem: the background of the JPG is now black instead of white! Before with 1: 1 conversion the background remained white.

Now i have an other problem with converting more than one file. I worte
for %%f in (*.pdf) do convert -resize "4000x4000^" "%%f".pdf "%%f".jpg
Unfortunatly it doesnt work - did i use a wrong term in Imagemagick?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert PDF to JPG with minimum side length

Post by snibgo »

I suspect your PDF background wasn't white, but transparent. Try "-background pink -layers flatten" after reading it. If the background is now pink, then that was the problem, and you should use white instead of pink.

"convert" should read the input, then process it, then write the output.
fffranz wrote:Unfortunatly it doesnt work ...
Give me a clue. What didn't work? What happened instead? Did you get an error message?
snibgo's IM pages: im.snibgo.com
fffranz
Posts: 8
Joined: 2016-10-16T03:24:31-07:00
Authentication code: 1151

Re: Convert PDF to JPG with minimum side length

Post by fffranz »

Hi Snibgo,
Thanks for your note - I try the same time. Best, the background would remain white.

Batch processing does not work. I have a For / Do loop to convert several different PDFs. They all have different sizes and I would like to have a minimum of 300 pixeln of all. In the window is always always: No such file or image ... I think I have a mistake in selecting the different files one after the other. Is %% f perhaps wrong?

Thank you for your suggestions.
fffranz
Posts: 8
Joined: 2016-10-16T03:24:31-07:00
Authentication code: 1151

Re: Convert PDF to JPG with minimum side length

Post by fffranz »

-background pink -layers flatten doesnt change anything. But no, the JPG is white again, i did nothing ;-)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert PDF to JPG with minimum side length

Post by snibgo »

Ah, I've seen the problem.

You set %%f to the filename, eg abc.pdf. But then you use "%%f%".pdf, so this will be abc.pdf.pdf.
snibgo's IM pages: im.snibgo.com
fffranz
Posts: 8
Joined: 2016-10-16T03:24:31-07:00
Authentication code: 1151

Re: Convert PDF to JPG with minimum side length

Post by fffranz »

You are right, sorry, i have problems with using this tokens. Is there an simple command, to convert (not to overwrite - like in mogrify) all PDF-files in an folder?
fffranz
Posts: 8
Joined: 2016-10-16T03:24:31-07:00
Authentication code: 1151

Re: Convert PDF to JPG with minimum side length

Post by fffranz »

mogrify -format jpg -resize "4000x4000^" *.pdf
This works now - and its simple enough for me. Thank you for your help!
Greetings from Berlin
Franz
fffranz
Posts: 8
Joined: 2016-10-16T03:24:31-07:00
Authentication code: 1151

Re: Convert PDF to JPG with minimum side length

Post by fffranz »

Finaly i use this batch convertign PDF in JPG:

mogrify -format jpg -resize "300x300^" -colorspace CMYK -type truecolor -quality 100 -set units PixelsPerInch -density 300 *.pdf

No black Background and good quality
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert PDF to JPG with minimum side length

Post by fmw42 »

Why do you want to convert to CMYK colorspace? That seem odd to me.
Post Reply