Results 1 to 2 of 2

Thread: Dynamically Resizing Images.

  1. #1
    Join Date
    Mar 2006
    Posts
    41
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Dynamically Resizing Images.

    I use something like this to resize dynamically images. Is there a way to wrap this in a function and class that when called returns the image object?
    PHP Code:
    <? 
    $src_img 
    imagecreatefromjpeg('./path/to/image.jpg'); 
    $srcsize getimagesize('./path/to/image.jpg'); 
    $dest_x 200
    $dest_y = (200 $srcsize[0]) * $srcsize[1]; 
    $dst_img imagecreatetruecolor($dest_x$dest_y); 
    imagecopyresampled($dst_img$src_img0000$dest_x$dest_y$srcsize[0], $srcsize[1]); 
    header("content-type: image/jpeg"); 
    imagejpeg($dst_img); 
    imagedestroy($src_img); 
    imagedestroy($dst_img); 
    ?>
    For exacmple, right now I could use it to dynamically resize images by having it inline in the HTML:
    Code:
    <img src="./image_script.php?img=image_name.jpg">
    But if it could be wrapped in a class / function, it could be done without exposing the script to possible exploitation maybe...

    I'd like to avoid resizing the image and dumping it in a temp directory. That could get huge.

  2. #2
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    As it only uses gd functions I don't see a way ti could be exploited

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
  •