Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post

    Changes to Element's thumbnail system.

    Im looking at Elements snippit here: http://codingforums.com/showthread.php?t=72029

    But there is something keeping me from using it again, Ive used in the past for something else. But what I want it to do is I want all my images to keep the same size ratio, so tall and thing pictures stay tall and thin, just get smaller. Last time I used it, it made everything exactly what I put for max height and max width.

  • #2
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,090
    Thanks
    2
    Thanked 23 Times in 23 Posts
    Are you getting an error message or what when you try to run this script? Saying that "there is something keeping me from using it" isn't particularly helpful to us. What exactly is happening? Did you use that script as-is or did you make modifications to it? If the latter, show us your code.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #3
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    no, like i said, the thing holding me back is:
    But what I want it to do is I want all my images to keep the same size ratio, so tall and thing pictures stay tall and thin, just get smaller.
    It works fine as it is, but it doesn't keep the size ratio of the image. That is what is holding me back. Sorry if I wasn't clear.

  • #4
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,090
    Thanks
    2
    Thanked 23 Times in 23 Posts
    Thanks for the clarification.

    Do you know what the dimensions are of one of the images you're trying to resize? If not, go into Windows Explorer and right click over the image to see the dimensions.

    Next, what do you have $max_width and $max_height set as in your script? And to repeat an earlier question, did you change anything in the original script? If so, what?
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #5
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts
    It doesn't keep the size ratio? It does for me. Try this out. Ignore the error jpg stuff or remove it.


    PHP Code:
    <?php 
        
        error_reporting
    (E_ALL);

        
    // Input 
        
    $s_image $_GET['image']; // Image url set in the URL. ex: thumbit.php?image=URL 
        
    $e_image "error.jpg"// If there is a problem using the file extension then load an error JPG. 
        
    $max_width 60// Max thumbnail width. 
        
    $max_height 100// Max thumbnail height. 
        
    $quality 100// Do not change this if you plan on using PNG images. 

        // Resizing and Output : Do not edit below this line unless you know what your doing. 

        
    if (preg_match("/.jpg/i""$s_image"))  { 

        
    header('Content-type: image/jpeg'); 
          list(
    $width$height) = getimagesize($s_image); 
        
    $ratio = ($width $height) ? $max_width/$width $max_height/$height;  
        if(
    $width $max_width || $height $max_height) {  
        
    $new_width $width $ratio;  
        
    $new_height $height $ratio;  
        } else { 
        
    $new_width $width;  
        
    $new_height $height
        }  
        
    $image_p imagecreatetruecolor($new_width$new_height); 
        
    $image imagecreatefromjpeg($s_image);  
        
    imagecopyresampled($image_p$image0000$new_width$new_height$width$height); 
        
    imagejpeg($image_pnull$quality);  
        
    imagedestroy($image_p);  

        } elseif (
    preg_match("/.png/i""$s_image"))  { 

        
    header('Content-type: image/png'); 
          list(
    $width$height) = getimagesize($s_image); 
        
    $ratio = ($width $height) ? $max_width/$width $max_height/$height;  
        if(
    $width $max_width || $height $max_height) {  
        
    $new_width $width $ratio;  
        
    $new_height $height $ratio;  
        } else { 
        
    $new_width $width;  
        
    $new_height $height
        }  
        
    $image_p imagecreatetruecolor($new_width$new_height); 
        
    $image imagecreatefrompng($s_image);  
        
    imagecopyresampled($image_p$image0000$new_width$new_height$width$height); 
        
    imagepng($image_pnull$quality);  
        
    imagedestroy($image_p);  

        } elseif (
    preg_match("/.gif/i""$s_image"))  { 

        
    header('Content-type: image/gif'); 
          list(
    $width$height) = getimagesize($s_image); 
        
    $ratio = ($width $height) ? $max_width/$width $max_height/$height;  
        if(
    $width $max_width || $height $max_height) {  
        
    $new_width $width $ratio;  
        
    $new_height $height $ratio;  
        } else { 
        
    $new_width $width;  
        
    $new_height $height
        }  
        
    $image_p imagecreatetruecolor($new_width$new_height); 
        
    $image imagecreatefromgif($s_image);  
        
    imagecopyresampled($image_p$image0000$new_width$new_height$width$height); 
        
    imagegif($image_pnull$quality); 
        
    imagedestroy($image_p);  

        } else { 


        } 

    ?>
    I think that's a older version... but I'm using it right now it it seems to work just fine

    http://chat.realmsrp.com/~dermetz/profile.php?U=Syn

    The image upper right is thumbnailed with that same script.

  • #6
    Regular Coder
    Join Date
    Apr 2004
    Posts
    298
    Thanks
    0
    Thanked 23 Times in 23 Posts
    If you need, here is another one to help.

    http://www.nstoia.com/toh/technical/...size/index.php

    Lite...

  • #7
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    Ok, I will try it. I just remember the past version of this not keeping a size ratio.
    Thanks


  •  

    Posting Permissions

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