Results 1 to 4 of 4

Thread: thumbnail viewer II outputting images

  1. #1
    Join Date
    Feb 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default thumbnail viewer II outputting images

    1) Script Title: Image Thumbnail Viewer II

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...thumbnail2.htm

    3) Describe problem: Outputting the images in the loadarea to be a maximum width.

    Hi guys, I've been working on this for ages and just cant seem to get it right. I have made a site and my own gallery using the thumbnail viewer with a bunch of php and my client wanted the images to be better quality... so i just increased the size of the images (being a bit of a n00b at php... actually website design in general) Now i want to view these images at a smaller size (800px max) and i simply cant resize the images on output.

    Ive tried modifying the stylesheet, and even inlined the code into the page itself. The site works fine with portrait images (having less width) but not work landscape, as you can see.

    Any bright ideas?

    http://www.kingslist.co.uk/gallery2.php?id=101&&start=0

  2. #2
    Join Date
    Aug 2009
    Posts
    92
    Thanks
    0
    Thanked 9 Times in 9 Posts

    Default

    put width=500 in the image----

    <div id='loadarea' style='max-width: 500px'><a href='http://www.kingslist.co.uk/gallery2.php?id=101&&start=1'><img src = 'http://www.kingslist.co.uk/Events/101-0.jpg' width=500></a></div>

  3. #3
    Join Date
    Feb 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hey thanks for the speedy reply. Unfortunately that still only resizes the first image that loads... but its a step in the right direction.

    Any other ideas?

  4. #4
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    http://pear.php.net/package/Image_Transform

    Then resize them with something like

    PHP Code:
    $file $uploaddir basename($_FILES['uploadfile']['name']); 
            require_once 
    'Image/Transform.php';
            
    //    
            //create transform driver object
            
    $it Image_Transform::factory('GD');
            if (
    PEAR::isError($it)) {
                die(
    $it->getMessage());
            }
            
    //load the original file
            
    $ret $it->load("$file");
            if (
    PEAR::isError($ret)) {
                die(
    $ret->getMessage());
            }
            
    //scale it to 100 pixels wide to make a thumb
            
    $ret $it->scaleByLength(100);
            if (
    PEAR::isError($ret)) {
                die(
    $ret->getMessage());
            }
            
    //save it into a different file
            
    $ext substr($file_name,strlen($file_name)-3,3);
            
    $clear_ext explode("." $ext$file_name);
            
    $file_name $clear_ext[0];
            
    $ret $it->save("$dir$custom$gallery$thumb$file_name"_file" $file_num $output_format);
            if (
    PEAR::isError($ret)) {
                die(
    $ret->getMessage());
            }
            
    //load the original file again
            
    $ret $it->load("$file");
            if (
    PEAR::isError($ret)) {
                die(
    $ret->getMessage());
            }
            
    //scale it to 500px wide, the main display
            
    $ret $it->scaleByLength(500);
            if (
    PEAR::isError($ret)) {
                die(
    $ret->getMessage());
            }
            
    //save it into a different file
            
    $ret $it->save("$dir$custom$gallery$file_name"_file" $file_num $output_format);
            if (
    PEAR::isError($ret)) {
                die(
    $ret->getMessage());
            } 
    Corrections to my coding/thoughts welcome.

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
  •