Jump to content


Photo

Help with picture uploading into thumbnails?


  • Please log in to reply
3 replies to this topic

#1 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 19 August 2006 - 08:20 PM

Ok, I know how to have people upload a picture.

Now, when they upload a picture, it will generate two versions - a porpotional thumbnail and the normal size pic they uploaded.

The old way I'm doing is, let the people upload the pic (regardless of the size). When I output the pic - I have it be a fixed size of "width=90" and "height=90". Some pics look distorted that way. Now, I want to take the height and width attributes off the img tag and show the thumbnail generaed image instead and when they click the thumbnail, it will show the normal size pic.

How can I do this?

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 19 August 2006 - 08:24 PM

Here's a start to getting thumbnails created at upload time

http://fundisom.com/...load_and_resize
Legend has it that reading the manual never killed anyone.
My site

#3 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 19 August 2006 - 11:13 PM

Thanks for the link.

Only problem is, it works for JPEG only right?

Plus, when I tried it on my localhost, it says the function imagecreatetruecolor was not found.

So, I decided to use a cheap trick I found at
http://www.sitepoint...ge-resizing-php

All it does is resize the image by dimension and not by the filesize.

#4 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 19 August 2006 - 11:33 PM

That's similar to what I plan to use for my site:
<?php
  function imageresize($max_width,$max_height,$image) {
    $dimensions=getimagesize($image);
    $width_percentage=round($max_width/$dimensions[0]);
    $height_percentage=round($max_height/$dimensions[1]);
    if ($width_percentage<=$height_percentage) {
      $new_width=$width_percentage*$dimensions[0];
      $new_height=$width_percentage*$dimensions[1];
    } else {
      $new_width=$height_percentage*$dimensions[0];
      $new_height=$height_percentage*$dimensions[1];
    }
    $new_image=array($new_width,$new_height);
    return $new_image;
  }
?>

Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users