Mario Legenda
Mario Legenda

Reputation: 759

resizing lots of images

I am working on a website for a retirement home in PHP and I made a user interface that has to resize a lot of images at the same time to a 300/300px size.

The user uploades a lot of images in a 'temp' directory, the when he wishes to save them, every one of those images gets resized to above size and both images are then saved and/or moved to different directories, depending on their size.

Large images to 'thumbnail' directory, resized small images to 'small' directory.

My question is, would there be any performance hits or script fails or script timeouts in that situation? For example, 50 images, total 50MB (or 200MB for that matter), all get resized in a loop one by one, and then, all of them saved and/or moved to their desired directories.

I haven't done this beacuse I'm on a deadline and I can't spend time doing this then finding out it's a bad design decision.

Thank you in advance

Upvotes: 0

Views: 49

Answers (1)

Alex Howansky
Alex Howansky

Reputation: 53563

Resizing 50 photos is likely too much processing to do while expecting the user to wait for it. In this case, I would recommend that your web app submit the work to a job queue and then immediately return to the user, with some sort of message that their photos will be processed soon. Then you have a continually running offline job that works on whatever is pending in the queue. This could be as simple as dropping the files in a directory and then running a shell script via cron, or could be something more elaborate like a Gearman worker.

Upvotes: 1

Related Questions