472,986 Members | 2,874 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,986 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 4682
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.