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

  • Home
  • SEARCH
  • 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 7809361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:24:45+00:00 2026-06-02T03:24:45+00:00

I’m coding a little CMS, where you can upload several images. These images are

  • 0

I’m coding a little CMS, where you can upload several images.
These images are converted into 3 versions (big, mid und thumbnail size) with imagemagick.

The problem is that imagemagick needs 5 minutes for creating these 3 versions of 4 pictures (which were uploaded).

here is the part with the imagemagick commands:

foreach($upIMGS as $key => $filename){
    list($width, $height) = getimagesize($path.$filename);
    if ($width > $height) $size = "x96";
    else $size = "96x";

    exec(P_IMAGEMAGICK." ".$path.$filename." -resize $size -gravity center -crop 96x96+0+0 +repage ".$path."th-".$filename);
    exec(P_IMAGEMAGICK." ".$path.$filename." -resize 320x320 ".$path."hl-".$filename);
    exec(P_IMAGEMAGICK." ".$path.$filename." -resize 514x ".$path."fl-".$filename);

    unlink($path.$filename);
}

[the $upIMGS is an array with all the filenames of the recently uploaded images]

I mean.. it does work, but toooo slow and after 5min the server gives me an error. some of the files are generated and some are not…

Would be very nice if you can give me a tip.

  • 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-02T03:24:46+00:00Added an answer on June 2, 2026 at 3:24 am

    I recently ran into the same issue, but I was only passing through the images once to resize them from their original 2592×1944 to 300xbestFit or bestFitx300

    I am using the PHP class imagick instead of command lines but I cut my time in half by changing to -scale or scaleImage in my case. Here is a snippet of my test code.

    while ($images = readdir($handle)) {
        // check to see if the first or second character is a '.' or '..', 
        // if so then remove from list
        if (substr($images,0,1) != '.') {
            //Check files to see if there extensions match any of the following image extensions. 
            // GLOB_BRACE looks for all glob criteria within the {braces}
            $images = glob($dir."{*.gif,*.jpg,*.png,*.jpeg}", GLOB_BRACE);
            // the glob function gives us an array of images
            $i = 0;
            foreach ($images as $image) {
                // parse the data given and remove the images/ $dir, 
                // imagemagick will not take paths, only image names.
                $i++;
                list ($dir, $image) = split('[/]', $image);
                echo $i, " ", $image, "<br />";
    
                $magick = new Imagick($dir."/".$image);
                $imageprops = $magick->getImageGeometry();
    
                if ($imageprops['width'] <= 300 && $imageprops['height'] <= 300) {
                    // don't upscale
                } else {
    
                    // 29 Images at 2592x1944 takes 11.555036068 seconds -> 
                    // output size = 300 x 255
                    $magick->scaleImage(300,300, true);
    
                    // 29 Images at 2592x1944 takes 23.3927891254 seconds -> 
                    // output size = 300 x 255
                    //$magick->resizeImage(300,300, imagick::FILTER_LANCZOS, 0.9, true);
                    $magick->writeImage("thumb_".$image);
    
                }
            }
        }
    }
    

    I am processing 29 images at 2592×1944 and went from 23.3927891254 seconds to 11.555036068 seconds. I hope this helps.

    Edit:

    In addition to what I said above I just ran into to the following, which might be helpful, on ImageMagick v6 Examples — API & Scripting:

    • “Shell scripts are inherently slow. It is interpreted, require
      multiple steps and extra file handling to disk. This is of course
      better thanks to the new IM v6 option handling, allowing you to do a
      large number of image processing operations in a single command. Even
      so you can rarely can do everything in a single convert command, so
      you often have to use multiple commands to achieve what you want.”

    • “When reading large or even a large number of images, it is better to
      use a Read
      Modifier
      to
      resize, or crop them, as IM does not them read in the full image,
      thus reducing its memory requirement.”

    • “If you call ImageMagick as an Apache module it will also reduce
      startup time, as parts will be loaded once and kept available for
      multiple use, rather than needing re-loading over and over. This may
      become more practical in the future with a permanently running
      ‘daemon’ IM process.”

    • 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
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;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'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
Does anyone know how can I replace this 2 symbol below from the string
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have just tried to save a simple *.rtf file with some websites and

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.