LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-25-2016, 08:26 PM   #1
gleftwich
LQ Newbie
 
Registered: Apr 2016
Posts: 1

Rep: Reputation: Disabled
I need help converting pdfs to jpegs.


How can I convert a pdf to a jpeg on linux Rebecca?
 
Old 04-25-2016, 08:33 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mageia, and whatever VMs I happen to be playing with
Posts: 12,773
Blog Entries: 17

Rep: Reputation: 3313Reputation: 3313Reputation: 3313Reputation: 3313Reputation: 3313Reputation: 3313Reputation: 3313Reputation: 3313Reputation: 3313Reputation: 3313Reputation: 3313
The easiest way is to open ("import") the PDF into the GIMP, then export it as a *.jpg or other desired format. If the GIMP is not already installed, it is in the Mint repos.

If PDF has multiple pages, you can use imagemagick: http://xmodulo.com/convert-pdf-files...-on-linux.html

Last edited by frankbell; 04-25-2016 at 08:34 PM.
 
2 members found this post helpful.
Old 04-25-2016, 09:05 PM   #3
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 3,303
Blog Entries: 1

Rep: Reputation: 685Reputation: 685Reputation: 685Reputation: 685Reputation: 685Reputation: 685
I tend to use a2ps for that. And then convert the .ps with gimp or convert (imagemagick). But mostly because I can extract individual pages and keep the correct landscape/portrait orientation with anything to postscript "a2ps". With the correct parameters. YMMV
 
Old 04-26-2016, 10:23 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,250

Rep: Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432
Quote:
Originally Posted by gleftwich View Post
How can I convert a pdf to a jpeg on linux Rebecca?
There are thousands of documents on Google about how to do this.

The "convert" command from Imagemagick can do it, and you can also play with the resolution/size of the images on output too.
The PDF toolkit (pdftk) may also work.

To convert a PDF to PNG with pretty good resolution:
Code:
convert -density 300 file.pdf file.png
To rotate a PDF:
Code:
pdftk nonrotated.pdf cat 1-endW output rotated.pdf
To size a PDF to a desired size (this example is A4):
Code:
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sPAPERSIZE=a4 -sOutputFile=output.pdf input.ps
 
1 members found this post helpful.
Old 04-26-2016, 02:49 PM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 6,740
Blog Entries: 3

Rep: Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624
+1 for imagemagick if you want automation; for a one-off gimp is probably best.
 
Old 04-26-2016, 03:35 PM   #6
Michael Uplawski
Member
 
Registered: Dec 2015
Location: Normandy, France
Distribution: Debian buster/sid
Posts: 538
Blog Entries: 18

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
With Ghostscript, you convert many files to many different image-formats. For a long time, already, I use the following script for this kind of work. I do not recommend the script and just put it here to economize on bad English. Examples are in general easier to understand... ;-)
Check the available Ghostscript devices. I know that for the output of tiffs the script had to be adapted once, but it should normally be okay, like it is.

Code:
#!/bin/bash
#
# prints files to image
# 2007-2016 Michael Upawski <michael.uplawski@uplawski.eu>
# License-agreement: Modify the file as pleases you; use at your own risk as it
# may do some harm somewhere or not (lay your home in ashes, make you crow's 
# feet and what not.., buys you a Volvo, you know that kind of stuff.)
# I forbid use of this script to any European governmental agencies as well as
# to each one of their paying customers. 

# defaults
TYPE=tif
DEV=tiff24nc
RES=400x400
PAPER=a4
GS=/usr/bin/gs
SCRIPT=`basename "$0"`

USAGE="Syntax:\n\tuser@machine:$PWD\$ $SCRIPT [file0] <file1> ... <filen>\nWill create 1 file converted to $TYPE for each page in any of the input-files.\
\n\tusr@machine:$PWD/\$ $SCRIPT <output type> [file0] <file1> ... <filen>\nWill instead create files of the specified output type e.g. jpeg, png, pgm"

if [ "$#" -gt 0 ]
then
	case "$1" in
		tif)
			TYPE=tif
			DEV=tiffscaled24
			shift 1
		;;
		tiff)
			TYPE=tiff
			DEV=tiffscaled24
			shift 1
		;;
		jpg)
			TYPE=jpg
			DEV=jpeg
			shift 1
		;;
		jpeg)
			TYPE=jpeg
			DEV=jpeg
			shift 1
		;;
		pgm)
			TYPE=pgm
			DEV=pgm
			shift 1
		;;
		png)
			TYPE=png
			DEV=png48
			shift 1
		;;
		pcx)
			TYPE=pcx
			DEV=pcx24b
			shift 1
		;;
		bmp)
			TYPE=bmp
			DEV=bmp256
			shift 1
		;;
	esac

	if [ "$#" -gt 0 ]
	then
		for inf in "$@"
		do
			ext=${inf}	
			DIR=`dirname "$inf"`
			if [ "$DIR"=='' ]
			then 
				DIR='.'
			fi
			OUTPUT="$DIR"/`basename "$inf" ."$ext"`_%04d."$TYPE" 
			echo "creating files $OUTPUT"	
			# /usr/bin/gs -SDEVICE="$DEV" -r"$RES" -sPAPERSIZE="$PAPER" -sOutputFile="$OUTPUT" -dNOPAUSE -dBATCH -- "$inf"
			"$GS" -SDEVICE="$DEV" -r"$RES" -sPAPERSIZE="$PAPER" -sOutputFile="$OUTPUT" -dNOPAUSE -- "$inf"
		done
	else
		echo -e "ERROR: No files"
		echo -e "$USAGE"
	fi
else
	echo -e "ERROR: No arguments."
	echo -e "$USAGE"
fi
Edit: I am a bit dumb, as I forgot that I even have a blog-entry on that subject..: Crete images from PDF and recreate PDF from images

Last edited by Michael Uplawski; 04-26-2016 at 03:40 PM. Reason: I am dumb.
 
1 members found this post helpful.
Old 04-26-2016, 08:55 PM   #7
Fred Caro
Member
 
Registered: May 2007
Posts: 999

Rep: Reputation: 166Reputation: 166
easy method, open a terminal and do:

Quote:
convert some.pdf some.jpg
in the relevant directory.

Fred.
 
Old 04-27-2016, 08:28 AM   #8
Michael Uplawski
Member
 
Registered: Dec 2015
Location: Normandy, France
Distribution: Debian buster/sid
Posts: 538
Blog Entries: 18

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
With convert, which quality setting do you use to ensure a decent conversion of text? -quality 100 is not enough, in my opinion.

Last edited by Michael Uplawski; 04-27-2016 at 08:32 AM.
 
Old 04-27-2016, 09:02 AM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,250

Rep: Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432Reputation: 4432
Quote:
Originally Posted by Michael Uplawski View Post
With convert, which quality setting do you use to ensure a decent conversion of text? -quality 100 is not enough, in my opinion.
See my post above. I get pretty good results with -density=300, but that's just for my use. Your mileage may vary.
 
1 members found this post helpful.
Old 04-27-2016, 01:13 PM   #10
Michael Uplawski
Member
 
Registered: Dec 2015
Location: Normandy, France
Distribution: Debian buster/sid
Posts: 538
Blog Entries: 18

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by TB0ne View Post
See my post above. I get pretty good results with -density=300, but that's just for my use. Your mileage may vary.
Thank you very much. I had misinterpreted the density option until now. Very fine!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Converting PDFS to ebooks (preferably epub or mobi) garpu Linux - Software 14 10-11-2014 02:07 AM
[SOLVED] bash script for auto converting images to pdfs zetrotrack000 Linux - Newbie 3 07-08-2014 09:59 AM
Cannot read a CD of jpegs in Mandrake 10! SpartacusJones Linux - Newbie 22 09-04-2004 11:09 PM
Trying to mount a CD with .jpegs on it soujrnr Linux - Software 2 08-13-2004 10:11 PM
Mandrake 9.2, mozilla and jpegs f0rmula Linux - Software 1 02-15-2004 09:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration