Results 1 to 3 of 3

Thread: Generating thumbnails in PHP

  1. #1
    Join Date
    Oct 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Generating thumbnails in PHP

    Hello

    I have a site where users have the option of uploading pictures when they make an entry. So I have a bunch of pictures in a sub-directory on the server.

    Whenever someone looks at an entry, the script will generate a link that can be clicked, and that shows the picture in a separate pop-up window.

    What I would like to do is to modify the script so that it will display a small thumbnail of the original picture on each entry.

    Can you help me creating a php function that takes a picture from the server and displays a small thumbnail ?

    Thanks in advance.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    There are two options here:
    Display the image smaller, so that it is preloaded when you view the large image.
    Or use php to render the image at a smaller size.

    For the first, it's just an issue of math. Just change the width to a certain percent, etc.

    For resizing with php:
    http://www.php.net/manual/en/functio...yresampled.php
    Example 2 should be helpful.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Oct 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Use the GD library to resize the image. You will have to have the code on a seperate document and call this page just like you would an image.

    <img src="image.php">

Bookmarks

Posting Permissions

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