SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2008
    Location
    Gloucestershire, UK
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Resizing 1000 images in a directory at once - would the server be able to cope?

    Hello,

    I've got 1000 images I need to resize, then make another thumbnail version, add the image name to a database, and I'm also think about producing a desaturated version.

    Is this something that the server could cope with, or should I put some kind of limit on the number of files processed.

    By the way, I'm using shared hosting.

    Cheers,

    Jon

  2. #2
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,396
    Mentioned
    61 Post(s)
    Tagged
    0 Thread(s)
    Probably, but I'll play safe and say that we need more info.

    What are the images being resized (consider 20 megapixel RAW images versus 20 KB JPEGs)? Will this need done be done repeatedly or is it a one-off? What were you hoping to use for the resizing (GD2, Imagemagick, something else)? Can you do the job locally and push the finished files to the shared server? Its details like these that we need to help give you a yay or nay.
    Salathe
    Software Developer and PHP Manual Author.

  3. #3
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Can you not resize them locally, ie, not on server?

    If you're intent on have the web server do it, process them a few at a time. Use the absence of the image name in the database as an indicator, whether to process the image or not.

    There are a bucket load of things that may affect the servers ability to cope, just try to play nice and add some common sense.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  4. #4
    SitePoint Zealot
    Join Date
    Jun 2008
    Location
    Gloucestershire, UK
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers, the images are jpegs of around 120-140kb. And I'll be using PHP GD(?) functions.

  5. #5
    SitePoint Zealot
    Join Date
    Jun 2008
    Location
    Gloucestershire, UK
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem, I'll limit them to about 50, shouldn't take too long to get them all done.

  6. #6
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,020
    Mentioned
    62 Post(s)
    Tagged
    0 Thread(s)
    If in doubt build a javascript/php loop.

    The php divides the task into groups of 50. When it completes a group it sends a response back to the browser and embedded in it is a javascript call to do the next batch. These calls echo back and forth until the task is done.

    If you are doing this as a cron you can do better by dividing the task on the first process and then forking off the actual builds to different process. This would be even faster since the OS can put the scripts onto different cores of the server as the task is parallel in nature. The only real bottleneck is disk access.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •