473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Efficient intense image resizing

Jim
I've heard that resizing images through PHP (either GD2 or ImageMagick)
is a processor intensive exercise. I'm setting up a site where users
will be uploading up to 10 images along with the details of their
product. For each image uploaded (max 500Kb), I'll be resizing it to
create a small, medium and large version after which I'll discard the
original. My worry is that as the site becomes more popular, the
processor time spent resizing images could badly effect the other areas
of the site (viewing/searching products).

Has anyone got any experience implementing a very high traffic site
where images are uploaded and resized? Any advice?

I saw somewhere on usenet a comment that using exec() to launch
ImageMagick to resize was quicker than using the PHP GD2 or ImageMagick
API, anyone had any experience of this? I would have though that either
way, the Apache thread dealing with the PHP script still has to wait
until the function call or the call to exec() has finished or is this
not the case? Does the exec() call run synchronously? Is there a
similar function which does run synchronously?

Finally, has anyone had any experience storing images in a MySQL DB
against storing in the standard file system? Much difference in
performance?

Jul 30 '05 #1
5 4709
On 2005-07-30, Jim <ji***@yahoo.com> wrote:
Finally, has anyone had any experience storing images in a MySQL DB
against storing in the standard file system? Much difference in
performance?


Well, a filesystem is specialized database for storing files.
Most people choose for an in-between solution:

- Store the files in the filesystem.
- Store the paths in the database (fe: mapping virtual and real fs)

--
Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be>
Jul 30 '05 #2
Jim wrote:
I've heard that resizing images through PHP (either GD2 or ImageMagick)
is a processor intensive exercise. I'm setting up a site where users
will be uploading up to 10 images along with the details of their
product. For each image uploaded (max 500Kb), I'll be resizing it to
create a small, medium and large version after which I'll discard the
original. My worry is that as the site becomes more popular, the
processor time spent resizing images could badly effect the other areas
of the site (viewing/searching products).


If you are getting large volumes of traffic, you could create a system
where photos to be resized are added to a queue, then only processed at
a rate that doesn't affect the rest of the website. If you have control
over the thread priority of the resizing task, set it to idle or below
normal, then it only runs when the server has nothing else to do.

Cheers,
Nicholas Sherlock
Jul 31 '05 #3
"Jim" <ji***@yahoo.com> writes:
I've heard that resizing images through PHP (either GD2 or ImageMagick)
is a processor intensive exercise. I'm setting up a site where users
will be uploading up to 10 images along with the details of their
product. For each image uploaded (max 500Kb), I'll be resizing it to
create a small, medium and large version after which I'll discard the
original.
I had used ImageMagick to resize images on a dual Intel Xenon
processor and found that the process was fast enough. Yes, the
process took up the CPU, but I the CPU did not get unduly overloaded.
If you have a slower processor, you will face problems.

The reason for not using GD libraries was that the server came with
GD1 and not GD2. GD1 did not have a few capabilities we wanted (true
colors, iirc)
My worry is that as the site becomes more popular, the processor
time spent resizing images could badly effect the other areas of the
site (viewing/searching products).
Serving pages, querying database backend are memory intensive
processes, not cpu bound processes.

I saw somewhere on usenet a comment that using exec() to launch
ImageMagick to resize was quicker than using the PHP GD2 or ImageMagick
API, anyone had any experience of this?


try to compare their outputs. Both of them take up CPU power.
Benchmark some images yourself using both the methods before going in
for any one of them. You can build your own Image class and then
change the underlying driver from IM to GD as your benchmarks
indicate.

--
Raj Shekhar
blog : http://rajshekhar.net/blog home : http://rajshekhar.net
Disclaimer : http://rajshekhar.net/disclaimer
Jul 31 '05 #4
In article <11**********************@g47g2000cwa.googlegroups .com>, Jim wrote:
I've heard that resizing images through PHP (either GD2 or ImageMagick)
is a processor intensive exercise. I'm setting up a site where users
will be uploading up to 10 images along with the details of their
product. For each image uploaded (max 500Kb), I'll be resizing it to
create a small, medium and large version after which I'll discard the
original. My worry is that as the site becomes more popular, the
processor time spent resizing images could badly effect the other areas
of the site (viewing/searching products).

Has anyone got any experience implementing a very high traffic site
where images are uploaded and resized? Any advice?
hard drives are cheap resize and store the scaled images and serve the
differently sized images from the files.
I saw somewhere on usenet a comment that using exec() to launch
ImageMagick to resize was quicker than using the PHP GD2 or ImageMagick
API, anyone had any experience of this? I would have though that either
way, the Apache thread dealing with the PHP script still has to wait
until the function call or the call to exec() has finished or is this
not the case? Does the exec() call run synchronously?
sometimes. especially if you have two or more processors...

recently I did some resizing (etc) using the netpbm suite of tools,
I've not timed it to see if it's faster or slower than image magick.
Finally, has anyone had any experience storing images in a MySQL DB
against storing in the standard file system? Much difference in
performance?


that depends to some extent on the standard file system. I would expect
the file system to be faster as apache is well optimisied for serving
static files...

--

Bye.
Jasen
Aug 19 '05 #5
"Jasen Betts" <ja*****@free.net.nospam.nz> wrote in message
news:55************@news.compass.net.nz...
In article <11**********************@g47g2000cwa.googlegroups .com>, Jim
wrote:

Finally, has anyone had any experience storing images in a MySQL DB
against storing in the standard file system? Much difference in
performance?


I too have had this question and have gotten basically the same response
from a lot of people. Storing images (or any binary data) in the DB itself
isn't generally recommended.

The first point they stated (pro-FS) was that the DB will serve your files
slower than the file system (most always - although I guess if your DB is on
a brand new quad cpu machine with SATA raid and the file system is on a 486
ATA-66 IDE drive then maybe not).

If the FS and DB are on the same machine, then the FS will serve your
content better, especially as traffic explodes.

Another point (pro-DB) was ease of backing up/restoring or transferring the
site. If EVERYTHING is in the DB, then all you have to do to move it or
restore it is insert a dump of your DB. If you put your binary data in the
FS, then you have to insert your DB backup, as well as FTP your files.

Personally, I've found that it's much more efficient to store large binary
data in the FS. I have had acceptable results with storing just a thumbnail
of an image in the DB itself, but not the full sized (2-5meg) image. The DB
wasn't horribly slow, but where the file system took less than a second to
serve my image, the DB took just over a second. For one client, it's a toss
up, but for 1000 hits a day, that'll get much worse.

-----------
Shawn Wilson
Aug 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: bissatch | last post by:
Hi, I have a collection of images stored in a DB. They are there for the purpose of a news system. When the user views the homepage it will diplay cropped versions of the news where the user...
3
by: Zahid Khan | last post by:
I need little help in my situation. I am reading a graphic file (jpg) from disk and then resizing it and save resized image. What happens, it gets blured, I want to retain same quality so that...
10
by: David W. Simmonds | last post by:
I have a DataList control that has an Image control in the ItemTemplate. I would like to resize the image that goes into that control. I have a series of jpg files that are full size, full...
8
by: berkshire | last post by:
Hi, Anyone know of a script out there that can resize images and not sacrifice image quality? I've been using phpthumb (http://phpthumb.sourceforge.net/) but when compared to an image resized...
9
by: tshad | last post by:
Is there a way to display images (imageButtons or linkbuttons for instance) as a max size (200px by 50px) and not have it stretch the image? What I want to be able to do is limit the real estate...
6
by: cbmeeks | last post by:
I am writing YAPSS (Yet Another Photo Sharing Site). Currently, the user can upload up to six pictures at once. When the uploads are complete, I then have a script that will resize the pix to...
9
by: kombu67 | last post by:
I'm reading a series of images from a MS SQL table and saving them to directory. These are staff ID pictures from our security card app. Once I've extracted the ID photo from the security app to...
10
by: mishrarajesh44 | last post by:
hii all, I am facing a problem currently.. i have a script for image uploading and resizing.. the image uploading takes place properly for every size images.. but, the resizing works for...
11
by: shapper | last post by:
Hello, I am displaying an image on a few pages. The image size is 50 px height and 50 px width. In some pages I need the image to be 30x30 px in others 40x40 px and in others 50x50px. Can I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.