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 8429847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:26:59+00:00 2026-06-10T05:26:59+00:00

I have a thumbnail creation script of a PDF file using Imagick PHP. It

  • 0

I have a thumbnail creation script of a PDF file using Imagick PHP.

It would create the thumbnail of the first page of the PDF file.

I am able to produce the thumbnail without any problem with fixed height and width

I have to get the height and width of the PDF file’s first page and have to calculate the thumbnail’s height and width accordingly.

If I have to create the thumbnail from an image, I can use getimagesize function in PHP, but is there any function like that to get the height and width of the first page of the PDF file ?

  • 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-10T05:27:00+00:00Added an answer on June 10, 2026 at 5:27 am

    You can access the first page of any multipage file format that ImageMagick can read by appending [0] to the filename.

    This means, that you can ask identify to print out width and height for the first page of a PDF with this command, which you should have no problem to translate into PHP syntax

     identify  -format "width: %W  --  height: %H\n"  some.pdf[0]
    

    This will print the values for the first pages MediaBox in the following format:

      width: 345  --  height: 777
    

    The unit of these values is PostScript points (where 72 pt == 1 inch). Of course you are free to modify the command to suite your needs, like giving out only 2 number values, or using the WxH format:

     identify  -format "%W %H\n"  some.pdf[0]
     identify  -format "%Wx%H\n"  some.pdf[0]
    

    However, be aware of the following facts:

    1. PDF also supports the optional TrimBox, CropBox, ArtBox and BleedBox settings.
    2. The most important of these is the TrimBox, because:
    3. Should the TrimBox be different from the MediaBox (it needs to be the same or smaller and isn’t allowed to be bigger!) then PDF viewers and printer drivers are asked to only render the part of the page that’s inside that box.
    4. identify will return the MediaBox values only, it does not have support for the other Boxes.
    5. Likewise, convert will use the (potentially bigger) MediaBox size of the PDF page to render the image (and thus its result will seemingly look different from what you see in a PDF viewer).
    6. Luckily, PDFs with TrimBox values which are very much different from the MediaBox values are not very common.
    7. If you need to get access to the value settings for all the Boxes, you should use a different command utility to extract the relevant info: pdfinfo -box -f 1 -l 1 some.pdf | grep -E '(Box:|rot:|size:)'. (Use the Poppler version of pdfinfo if possible…)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php script to create jpg thumbnail of pdf as follows; <?php
I have a simple PHP script using imagecreatefromjpeg to create a thumbnail version of
I have photo gallery code that does image re-sizing and thumbnail creation. I use
I have encountered a problem with creating a thumbnail from an uploaded image file,
I have created thumbnail view using Three20 bundle. I have successfully loaded and displayed
I have a video thumbnail on my page, with a little icon Thumbs Down.
I am using the following code in my website, for thumbnail creation: string furl
Can we create a popup within a popup. I have a thumbnail image and
I have this thumbnail list and would like push the image paths (sources) into
I have a thumbnail control where I am adding Images using openfiledialog and after

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.