Jump to content

Photo Upload - Very Basic


johnsmith153

Recommended Posts

I have used the same method for uploading photos for ages but feel there may be a better way.

 

For both methods, please assume all uploads are large digital camera uploads of a few megabytes and thousands of pixels wide (as you would expect from large digital camera images).

 

CURRENT METHOD

 

(1) receive uploaded file and use ImageMagick to convert to 4 file sizes, then store these file sizes (also set so ImageMagick reduces the quality to something like a setting of 80 out of 100 which will further reduce file size.

- file sizes (widths):

800

240

120

60 (mobile phones etc.)

(2) Based on the type of size and view required I then use <img src="/photos/240/file.jpg to display (240 being the required image size of course)

 

POSSIBLE BETTER METHOD

(1) Use ImageMagick to reduce to 800 wide as will never display bigger than this anyway, reduce quality also. But don't resize further and only need one file.

(2) Use PHP commands to display an image, and set height/width/quality then. Eg: <img src="showImage.php?file=file.jpg&width=240&quality=60

 

So both would do the same thing but the second seems better as you don't need to create 4 images for every photo upload. Why make lots of thumbnails when you can make one and then get PHP to create at the time of display?

 

Although I suppose if you regularly displayed these images in a search result then PHP would need to do that extra processing on every search. Creating all 4 at the time of upload only requires the one bit of processing.

 

Have I just found the answer?

Link to comment
Share on other sites

The difference will be in bandwidth used and browser processing. When you set the width and or height of an IMG tag, that ONLY changes the way it displays (the browser has to shrink or stretch the image) it does NOT change the amount of data sent to the browser.  So, if you use a single image, and let's just say it is 1.4MB, then it will ALWAYS transfer 1.4MB from the server to the browser regardless of how big the browser displays it.  This is a lot of data for slow connections, and chews up your bandwidth allowance (if your hosting plan has a limit).

 

If you resize the images on upload, you are using server CPU time (once) and disk space for storage, but then when you send an image to the browser, you are sending less data (using less bandwidth) with the "60" size than with "800" size.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.