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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:21:03+00:00 2026-05-10T15:21:03+00:00

I’m currently using ImageMagick to determine the size of images uploaded to the website.

  • 0

I’m currently using ImageMagick to determine the size of images uploaded to the website. By calling ImageMagick’s ‘identify’ on the command line it takes about 0.42 seconds to determine a 1MB JPEG’s dimensions along with the fact that it’s a JPEG. I find that a bit slow.

Using the Imagick PHP library is even slower as it attemps to load the whole 1MB in memory before doing any treatment to the image (in this case, simply determining its size and type).

Are there any solutions to speed up this process of determining which file type and which dimensions an arbitrary image file has? I can live with it only supporting JPEG and PNG. It’s important to me that the file type is determined by looking at the file’s headers and not simply the extension.

Edit: The solution can be a command-line tool UNIX called by PHP, much like the way I’m using ImageMagick at the moment

  • 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. 2026-05-10T15:21:03+00:00Added an answer on May 10, 2026 at 3:21 pm

    Sorry I can’t add this as a comment to a previous answer but I don’t have the rep. Doing some quick and dirty testing I also found that exec(‘identify -ping… is about 20 times faster than without the -ping. But getimagesize() appears to be about 200 times faster still.

    So I would say getimagesize() is the faster method. I only tested on jpg and not on png.

    the test is just

    $files = array('2819547919_db7466149b_o_d.jpg', 'GP1-green2.jpg', 'aegeri-lake-switzerland.JPG'); foreach($files as $file){   $size2 = array();   $size3 = array();   $time1 = microtime();   $size = getimagesize($file);   $time1 = microtime() - $time1;   print '$time1 \n';   $time2 = microtime();   exec('identify -ping $file', $size2);   $time2 = microtime() - $time2;   print $time2/$time1 . '\n';   $time2 = microtime();   exec('identify $file', $size3);   $time2 = microtime() - $time2;   print $time2/$time1 . '\n';   print_r($size);   print_r($size2);   print_r($size3); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 59k
  • Answers 59k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Well the first step in receiving help with a warning… May 11, 2026 at 9:01 am
  • added an answer One way might be to lie to the Entity Framework… May 11, 2026 at 9:01 am
  • added an answer I think you're confusing something there. A buffer is something… May 11, 2026 at 9:01 am

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.