473,762 Members | 8,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4729
On 2005-07-30, Jim <ji***@yahoo.co m> 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.co m> 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************ **********@g47g 2000cwa.googleg roups.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.n et.nospam.nz> wrote in message
news:55******** ****@news.compa ss.net.nz...
In article <11************ **********@g47g 2000cwa.googleg roups.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
2539
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 will them click the 'read more' link to view the entire article. It will also display a thumbnail of the article image. As the image is stored at its full display size in the DB I need to be able to resize it before outputing it.
3
12411
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 small image won't be blur? any tips or idea or technique? Thanks in Advance.
10
4162
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 resolution (ie. large). I have a database that contains references to the pictures. Currently I have to resize the jpgs manually, and then point the ImageUrl property at that jpg using databinding. This works fine. I would like to avoid the resizing step...
8
3689
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 in photoshop it's products are not as good (yeah I upped the image quality and tried out some filters - no luck). Tutorials or scripts online preferred are preferred, but if you know of a way to change the settings on phpthumb to maintain the...
9
4419
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 an image can take up but not stretch the image if it happens to be 150px by 40. I am doing commands such as: <asp:ImageButton ID="CompanyLogo" onClick="Image_Click" Width="200px" Height="50px" runat="server"/>
6
1536
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 different thumbnails for speed. However, imagine resizing 6 pictures of 2300x2200 pixels in 6 different sizes (maintaining the best quality I can) on a Pentium 3 450Mhz running Ubuntu and 384 megs of ram. Seriously.
9
9641
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 disk, I need to reference the disk file in our HR app. As part of the process, I'm resizing the image and changing its resolution from 96 to 72 dpi. If they are not at a 72 dpi resolution, the HR app freezes. The resizing works without a hitch, but...
10
7072
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 only small sized iamages.. for eg. resizing takes place for 70 kb sized images but fails for 600kb or more.. my code is below..
11
5818
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 scale the image using CSS? Thanks,
0
9378
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10137
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9989
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9812
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8814
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5268
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3914
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.