Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 12-18-2009, 03:40 PM   #1
LQ Newbie
Registered: Oct 2008
Posts: 5

Rep: Reputation: 0
rasterize pdf made up of multiple bitmap slices / page


I have a PDF file made up of 4 vertically-stacked bitmap images per page (output from a scan job). Running "pdfimages" on it produces 4 separate images for each page.

I want to produce a single bitmap image for each page, WITHOUT resampling the embedded bitmaps.

ImageMagick's "convert" is not a solution, because it re-samples (resizes) the embedded bitmaps. By default it resamples at 72dpi. The dpi can be changed with the '-density' option, but the "true" dpi is a fractional value (205.72685432...) and so the resolution would always be inexact.

Is there a way to just preserve the resolution of the embedded bitmaps when rendering each page? Both 'convert' and ghostscript annoyingly ignore that intrinsic resolution of the bitmaps and default to 72 dpi.

It seems like such a simple operation, equivalent to displaying each page at 100% in xpdf or acroread. But I don't see any command-line tools to do it.
Old 12-21-2009, 10:18 AM   #2
Senior Member
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,295

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335

Why not use pdfimages to pull out the 4 images, and then imagemagick to combine them? If the PDF files always have the same sizes, it shouldn't be very difficult to write a little script to do the job.

For information about doing this with imagemagick:

Maybe play with the montage command until you find one that will do the job? And then put it in a little script.
Old 12-21-2009, 06:10 PM   #3
LQ Newbie
Registered: Oct 2008
Posts: 5

Original Poster
Rep: Reputation: 0

I ended up doing something like that... However it seems that the slices are not necessarily vertically contiguous (i.e. where there was a vertical gap on the page, the scanning software skipped it). Therefore, after assembling the slices, I obtained pages of varying height.

The fact that pdfimages doesn't report which images came from which page was a big nuisance (the original PDF had some pages with 4 slices and some with a single slice).

At the very least I wish pdfimages could report the location (page, x and y) of the various images it pulls out of a PDF, instead of dumping a heap of sequentially-numbered image files. It seems like such a silly omission. The other thing that I found annoying is imagemagick's propensity to silently resample images.

Oh well, I guess we're lucky to have even these tools...

Last edited by danutz; 12-21-2009 at 06:12 PM.


ghostscript, graphics, imagemagick, pdf

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
how to find PDF page count mfoley Programming 8 02-26-2009 03:55 PM
Web page to PDF miykle Linux - Newbie 2 04-04-2008 06:07 AM
Printing html page to pdf with links MikeyCarter Linux - Software 1 11-16-2006 07:20 PM
Print PDF - blank page Trio3b Linux - General 1 12-10-2005 02:00 AM
printing from multiple pdf files the first page harmster Linux - Software 2 05-09-2005 08:06 AM > Forums > Linux Forums > Linux - Software

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

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