Results 1 to 3 of 3

Thread: Optimize images for web ...on upload?

Hybrid View

  1. #1
    Join Date
    Apr 2011
    Seattle, WA

    Exclamation Optimize images for web ...on upload?

    I'm building a CMS for a client who is definitely not very computer savvy. They will be uploading a lot of photos and they are scared of "big" words like "optimization" and "photoshop" so they are more likely just going to upload photos straight from their camera's SD card. This is bad, obviously, because those files will be huge.

    Is there a way to use PHP to resize and optimize an image during the upload process (or upload, fix, save a copy, then delete the original, etc, if it has to come to that) that can save them disk space and make their website run faster. I don't want them to call me somewhere down the line and yell at me for not giving them enough disk space, because they really do have plenty.

    I'm going to be using jQuery on the website and jQuery mobile in the CMS (I'm better with development than with design, so this just speeds up the process for me) -- so I'll probably be using some kind of drag-and-drop file-uploader that can handle multiple files and multiple downloads (not necessarily simultaneous) but all I really need is a good PHP function to fix the photos they upload.

    (The client is a tattoo shop, I'm working for free for them because one of them was friends with my mom)

    Thanks in advance for any help or advice -- it's greatly appreciated!

  2. #2
    Join Date
    Aug 2004
    Seems like a relatively straight-forward operation for the GD Image functions, or possibly the ImageMagick library if you have it installed.

    With GD, the basic process would be to use imagecopyresampled() to resize it, then use imagejpeg() to save it, using the 2nd parameter for the output file path-name and the 3rd parameter to specify the desired image quality. For an example of resizing code, here's something I wrote a few years ago (and as such probably would write a bit differently now ): http://www.charles-reace.com/blog/?s=image+resize
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Apr 2011
    Seattle, WA
    Thank you for pointing me in the right direction, and for responding so quickly. I tried googling an answer before I posted here and I couldn't figure out the right thing to search for. Thank you so much.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles