Image Resizing

Discussion in 'PHP' started by simnorwebdesign, Feb 16, 2008.

  1. #1
    Hi, I need to resize images when the user uploads and create a new image (thumbnail), but I dont want it to look all distorted, is there a way in php to resize images without losing the quality of the image.

    Thanks in advance

    Simon
     
    simnorwebdesign, Feb 16, 2008 IP
  2. 2WDH.com

    2WDH.com Active Member

    Messages:
    143
    Likes Received:
    3
    Best Answers:
    5
    Trophy Points:
    68
    #2
    Hi Simon.

    Please check imagecopyresampled PHP function. You can find some imagecopyresampled thumbnail creation examples at PHP website.
     
    2WDH.com, Feb 16, 2008 IP
  3. walkere

    walkere Active Member

    Messages:
    112
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Yes. The GD library is good for resizing images. As long as you shrink them, there's no real loss of quality. It just doesn't work well when you try to make them bigger... =)

    The relevant functions you'll be looking at are imagecreatefrom*, getimagesize, imagecreatetruecolor, imagecopyresampled, and image* - where * is the proper extension (i.e. png, jpeg, gif).

    Try reading through the relevant chapter of Practical PHP Programming on working with images. It's got some good examples for creating/resizing an image. If you look through the PHP Tutorials in my sig, there's also an old tutorial on resizing images that might be useful.

    Good luck,
    - Walkere
     
    walkere, Feb 16, 2008 IP