LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-23-2015, 05:13 AM   #1
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Rep: Reputation: 255Reputation: 255Reputation: 255
Converting a PDF to Tiff for each page with Ghostscript?


Hello,

I have found this command for a single page.
Code:
gs -q -dNOPAUSE -r600 -sDEVICE=tiff24nc -sOutputFile=a.tif a.pdf -c quit
However I would like that GS creates for each page a TIFF file.

Looking forward to hearing you.

Tuxi
 
Old 03-23-2015, 08:22 AM   #2
mjolnir
Member
 
Registered: Apr 2003
Posts: 815

Rep: Reputation: 99
This page appears to have an answer: http://stackoverflow.com/questions/1...multipage-tiff

I have not tried it.

Edit0: My first try failed, hmmm.
Edit1: A second "hmmm", they (individual images) are created because I can open them up with Gimp. Maybe I need a third cup of coffee.

Last edited by mjolnir; 03-23-2015 at 09:08 AM.
 
Old 03-23-2015, 09:23 AM   #3
mjolnir
Member
 
Registered: Apr 2003
Posts: 815

Rep: Reputation: 99
If you have ImageMagick installed "identify" will show the individual file names on the cli and "display" will open the file on the X server.
 
Old 03-23-2015, 03:36 PM   #4
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by mjolnir View Post
If you have ImageMagick installed "identify" will show the individual file names on the cli and "display" will open the file on the X server.
I would prefer to use GS since it is much faster and stabler than imagemagick.
 
Old 03-23-2015, 05:37 PM   #5
mjolnir
Member
 
Registered: Apr 2003
Posts: 815

Rep: Reputation: 99
Quote:
Originally Posted by Xeratul View Post
I would prefer to use GS since it is much faster and stabler than imagemagick.
Did you try the "gs" commands on the link? As far as I can tell they work fine.
 
Old 03-23-2015, 06:28 PM   #6
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
I use this in one of my scripts:
Code:
/usr/bin/gs -sDEVICE=png16m -r 200 -o outfile-\%02d.png infile.pdf
This is a call to convert a pdf to multiple PNGs. You'd need a different sDEVICE for TIFF. Note the %02d. It specifies how the output files are numbered. I am not sure about the space in -r 200 between r and 200. In my script there is no space.

jlinkels
 
Old 03-23-2015, 08:54 PM   #7
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,623

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
i have never had issues with netpbm
it is default installed on most systems

"pdftoppm"

or part of PS
"pdftops"
or
pdfdetach

and
"pdfimages"

--- built in tiff support
Code:
 pdfimages --help
pdfimages version 0.26.5
Copyright 2005-2014 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1996-2011 Glyph & Cog, LLC
Usage: pdfimages [options] <PDF-file> <image-root>
  -f <int>       : first page to convert
  -l <int>       : last page to convert
  -png           : change the default output format to PNG
  -tiff          : change the default output format to TIFF
  -j             : write JPEG images as JPEG files
  -jp2           : write JPEG2000 images as JP2 files
  -jbig2         : write JBIG2 images as JBIG2 files
  -ccitt         : write CCITT images as CCITT files
  -all           : equivalent to -png -tiff -j -jp2 -jbig2 -ccitt
  -list          : print list of images instead of saving
  -opw <string>  : owner password (for encrypted files)
  -upw <string>  : user password (for encrypted files)
  -p             : include page numbers in output file names
  -q             : don't print any messages or errors
  -v             : print copyright and version info
  -h             : print usage information                                                                                                               
  -help          : print usage information                                                                                                               
  --help         : print usage information                                                                                                               
  -?             : print usage information
 
Old 03-23-2015, 09:48 PM   #8
gEEk_X99
LQ Newbie
 
Registered: Mar 2015
Posts: 6

Rep: Reputation: Disabled
@ Xeratul

You need to add a "%d" as part of the output filename, like so:

Code:
gs -q -dNOPAUSE -r600 -sDEVICE=tiff24nc -sOutputFile=a%d.tif a.pdf -c quit
I've tested it myself on my pdf file and it worked just fine and it made a series of tif pages in numerical order. Let us know if this works for you.

PS: The conversion is not instant. It will take a few seconds or more depending on length and complexity of the pdf file.

Last edited by gEEk_X99; 03-24-2015 at 12:35 AM.
 
Old 03-24-2015, 01:32 PM   #9
gEEk_X99
LQ Newbie
 
Registered: Mar 2015
Posts: 6

Rep: Reputation: Disabled
Did it work for you Xeratul? It should.

Here is an excerpt of the manpage for gs

Quote:
You might want to print each page separately. To do this, send the output to a series of files "foo1.xyz, foo2.xyz, ..." using the "-sOutputFile=" switch with "%d" in a filename template:

-sOutputFile=foo%d.xyz

Each resulting file receives one page of output, and the files are numbered in sequence. "%d" is a printf format specification; you can also use a variant like "%02d".

Last edited by gEEk_X99; 03-24-2015 at 01:52 PM.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
converting tiff to jpeg freebies Linux - Software 8 06-26-2013 10:17 PM
PDF to TIFF chr15t0 Linux - Software 5 05-09-2013 09:47 AM
Tiff to PDF cipher7836 Linux - Newbie 6 10-12-2012 07:09 PM
Single Page tiff to Multi Page tiff James_dean Programming 3 11-10-2005 10:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:09 AM.

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
Open Source Consulting | Domain Registration