You want to convert PDF to image for free? You are in the right place!
You can even automate the process in batch!
We will use Brew to install all the necessary stuff to convert PDF in JPEG, JPG, PNG or other images format.
1. Go to http://brew.sh/ and paste into a terminal the installation string:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2. Install ImageMagick with Brew:
brew install imagemagick
3. Install GhostScript with Brew: (used for PDF conversion)
brew install ghostscript
4. Ready to go!
Type name of file you want to convert followed by save name of the converted file and the format you want:
Type name of file you want to convert followed by save name of the converted file and the format you want:
PDF to JPG
convert SourceFile.pdf DestinationFile.jpg
PDF to PNG
convert SourceFile.pdf DestinationFile.png
If converted images have a black background instead of white, you have to set default background as white and remove transparency:
-background white -alpha remove
So command will be:
convert SourceFile.pdf -background white -alpha remove DestinationFile.png
Resize output images:
convert SourceFile.pdf -resize <Width>x<Height> DestinationFile.jpg
We can specify only one dimension or both like:
Resize as 600px width:
convert SourceFile.pdf -resize 600x DestinationFile.jpg
Resize as 600px height:
convert SourceFile.pdf -resize x600 DestinationFile.jpg
Resize both as squared 600x600:
convert SourceFile.pdf -resize 600x600 DestinationFile.jpg
Resize shortest dimension to preserve aspect ratio (use '^' operator):
convert SourceFile.pdf -resize 600x600^ DestinationFile.jpg
You want to convert file in batch?
Create a script file with this:
#!/bin/bash # Remove *.jpg *.JPG *.jpeg from list of filesshopt -s nullglob for FILE in *.jpg *.JPG *.jpeg; do convert "$FILE" -resize x150 "$FILE""_x150.jpg" done
Save it in a file with .sh extension and from terminal do this to make it executable:
chmod +x file.sh
Then execute this in you images folder:
./file.sh
It will convert and save the result of all the .jpg images in that folder.
Let me know if helped!
Nessun commento:
Posta un commento