SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to display the thumbnail please help!

    Hello All,

    I need your help for thumbnail.I have an image gallery containing say 200 images.
    All images are having different dimensions.ex image1 is 800 by 600
    and image2 is 2010 by 2000.
    Now I want a page which displays the thumbanail of all the images with equal size
    say 125 by 125.

    Please help me how do I create thumbanail of equal size for all the images which are having different dimension.

    Your help will be highly appreciated.

    Thanks in advance.
    Barbara

  2. #2
    SitePoint Evangelist tangledman's Avatar
    Join Date
    Sep 2005
    Location
    Puerto de Mazarron, Murcia, Spain
    Posts
    425
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can either modify the images by height or width. Otherwise you don't preserve the aspect ratio, which results in a sheered image.

    You could do a batch resize. using http://www.irfanview.com/

    How are the image uploaded originally? you could create a resized version when you upload the version.

  3. #3
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks tangledman,

    I have also found one php thumbnail creator.Here is the link
    thumbnail

    I am going to try this.
    Barbara

  4. #4
    SitePoint Enthusiast thenk83's Avatar
    Join Date
    Sep 2005
    Location
    Hacienda Heights, CA
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a photography site where I created thumbnails. I used GD to process the images and resize. Works well!
    Mmmmm .NET...PHP...CF...
    AIM: THENK83
    MSN: thenk83@hotmail.com

  5. #5
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello thenk83,

    Actually I used phpthumbnail I have given the link in previous post.
    Could you please explain me in short how did you use GD.If I find it easy than
    phpthumbnail I will also try to implement.

    Thanks,
    Barbara

  6. #6
    SitePoint Enthusiast thenk83's Avatar
    Join Date
    Sep 2005
    Location
    Hacienda Heights, CA
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function h_thumb_sizer($userfile, $width, $height){
    	global $thumb_output;
    	$white_border_px = '1';
    	$black_border_px = '2';
    	$thumb_width = '170';
    	$thumb_height = '113';
    	$real_path_userfile = '/path/to/originals/'. $userfile;
    	$path_thumb = '/path/to/originals/thumbnails/'. $userfile;
    	$dest = imagecreatetruecolor($thumb_width, $thumb_height);
    	$black_color = imagecolorallocate($dest, 0, 0, 0);
    	$white_color = imagecolorallocate($dest, 255, 255, 255);
    	$src = imagecreatefromjpeg($real_path_userfile); 
    	$final = imagecopyresampled($dest, $src, 0, 0, 0, 0, $thumb_width,    $thumb_height, $width, $height);
            // BLACK & WHITE 1PX BORDER
    	imageline($dest, 1, 0, 1,111, $black_color); // LEFT SIDE
    	imageline($dest, 0, 1,168,1, $black_color); // TOP SIDE
    	imageline($dest, 168, 0,168,111, $black_color); // RIGHT SIDE
    	imageline($dest, 0, 111, 168, 111, $black_color);	// BOTTOM SIDE
    	imageline($dest, 0, 0, 0,170, $white_color); // LEFT SIDE
    	imageline($dest, 0, 0,170, 0, $white_color); // TOP SIDE
    	imageline($dest, 169, 0,169,112, $white_color); // RIGHT SIDE
    	imageline($dest, 0, 112, 169, 112, $white_color);	// BOTTOM SIDE
    	$thumb_output = imagejpeg($dest, $path_thumb, 100);
    }

    http://www.dantignacphoto.com/
    Thats my site check out thumbnails.
    Mmmmm .NET...PHP...CF...
    AIM: THENK83
    MSN: thenk83@hotmail.com

  7. #7
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have tried your function but I am getting only the some portion of the image.
    i.e. image is not getting resize.
    Am I doing wrong?

    PHP Code:
    function h_thumb_sizer($userfile, $width, $height){
        global $thumb_output;
        $white_border_px = '1';
        $black_border_px = '2';
        $thumb_width = '170';
        $thumb_height = '113';
        $real_path_userfile = 'original/'. $userfile;
        $path_thumb = 'thumb/'. $userfile;
        $dest = imagecreatetruecolor($thumb_width, $thumb_height);
        $black_color = imagecolorallocate($dest, 0, 0, 0);
        $white_color = imagecolorallocate($dest, 255, 255, 255);
        $src = imagecreatefromjpeg($real_path_userfile); 
        $final = imagecopyresampled($dest, $src, 0, 0, 0, 0, $thumb_width,    $thumb_height, $width, $height);
            // BLACK & WHITE 1PX BORDER
        imageline($dest, 1, 0, 1,111, $black_color); // LEFT SIDE
        imageline($dest, 0, 1,168,1, $black_color); // TOP SIDE
        imageline($dest, 168, 0,168,111, $black_color); // RIGHT SIDE
        imageline($dest, 0, 111, 168, 111, $black_color);    // BOTTOM SIDE
        imageline($dest, 0, 0, 0,170, $white_color); // LEFT SIDE
        imageline($dest, 0, 0,170, 0, $white_color); // TOP SIDE
        imageline($dest, 169, 0,169,112, $white_color); // RIGHT SIDE
        imageline($dest, 0, 112, 169, 112, $white_color);    // BOTTOM SIDE
        $thumb_output = imagejpeg($dest, $path_thumb, 100);
        return $thumb_output;
    }

    if(h_thumb_sizer("myImage.jpg",600,600))
    {
    ?>
    <html>
        <body>        
    <img src="thumb/myImage.jpg" />
    </body>
    </html>
    <?
    }
    The image is having the size of 2880 by 2160

    Thanks,
    Barbara


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
  •