Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8630221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:00:59+00:00 2026-06-12T09:00:59+00:00

I’ve written a script to use ImageMagick to convert PDFs into JPGs for each

  • 0

I’ve written a script to use ImageMagick to convert PDFs into JPGs for each page, along with resizing/etc.

Where it gets slightly more tricky is some PDFs have the middle two-page spread as “one page” – so it is extra wide. Is there ANY way to “detect” this and crop the left and right sides, as two separate pages?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:01:00+00:00Added an answer on June 12, 2026 at 9:01 am

    Assuming you want to use ImageMagick (and only ImageMagick) for this: that can’t be done. ImageMagick cannot process PDF input all by itself. It has to make use of Ghostscript anyway, so without a local Ghostscript installation it won’t work. (You will not necessarily see Ghostscript at work while you feed PDF input to ImageMagick, unless you add a -verbose to its command line, because ImageMagick’s delegation of the job to Ghostscript happens behind your back…)

    Your question has two parts:

    • "Is there a way to "detect" extra wide pages, like the center spreads?"
    • "Is there a way to crop the left and right parts from center spreads as two separate pages?"

    Detect page sizes

    You can use ImageMagick’s identify to detect the page sizes of a PDF.

    Just run the most simple command:

    identify multipage.pdf

    The output will be s.th. like

    multipage.pdf[0] PDF 595x792 595x792+0+0 16-bit Bilevel DirectClass 59.5KB 0.000u 0:00.000
    multipage.pdf[1] PDF 595x792 595x792+0+0 16-bit Bilevel DirectClass 59.5KB 0.000u 0:00.000
    multipage.pdf[2] PDF 595x792 595x792+0+0 16-bit Bilevel DirectClass 59.5KB 0.000u 0:00.000
    multipage.pdf[3] PDF 595x792 595x792+0+0 16-bit Bilevel DirectClass 59.5KB 0.000u 0:00.000
    

    The output’s page count is 0-based. So [0] indicates the first page, [1] the second page, etc.

    To customize the output a bit better, you could do this:

    identify -format '%f, page %s + 1: %W x %H\n' multipage.pdf
    

    and get

    multipage.pdf, page  0 + 1: 595 x 792
    multipage.pdf, page  1 + 1: 595 x 792
    multipage.pdf, page  2 + 1: 595 x 792
    multipage.pdf, page  3 + 1: 595 x 792
    

    For a double-spread page the respective output should be 1190 x 792 or similar.

    However, be warned: to use ImageMagick for querying the page sizes of PDF files is veeeery slow. Therefor, better use a different tool for this sub-task: pdfinfo. This will be faster by several orders of magnitude:

    pdfinfo -f 1 -l 1000 -box multipage.pdf
    

    will output

    Pages:          4
    Page    1 size: 595 x 792 pts
    Page    1 rot:  0
    Page    2 size: 595 x 792 pts
    Page    2 rot:  0
    Page    3 size: 595 x 792 pts
    Page    3 rot:  0
    Page    4 size: 595 x 792 pts
    Page    4 rot:  0
    

    If you need additional info about the pages’ ArtBox, TrimBox, BleedBox and CropBox values, just add -box to the commandline.

    As I said: pdfinfo is significantly faster in identifying page sizes for PDFs than ImageMagick is. Use the right tool for the job.

    Crop left and right parts of a page

    Now that you have identified the large double-spread page, you could use one of the following methods (based on Ghostscript) to split down the pages in the middle:

    • How to crop a section of a PDF file to PNG using Ghostscript
    • Split one PDF page into two
    • Convert PDF 2 sides per page to 1 side per page
    • How can I split a PDF’s pages down the middle?

    Adapting the method described in above links will result in 2 PDF pages that still contain all their original vector and font info.

    Alternatively, you can use ImageMagick. Assuming your ‘double-spread’ page is of dimension 1190×842 pt, based on A4 (595×842 pt), and assuming it is page 16 (which translates to [15] for ImageMagick) inside an original PDF, your convert commands could be s.th. like:

    convert  multipage.pdf[15]  -crop 595x842+0+0    page16-left.png
    convert  multipage.pdf[15]  -crop 595x842+595+0  page16-right.png
    

    The result gives you two raster images.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I am currently running into a problem where an element is coming back from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.