Jump to content

Help with picture uploading into thumbnails?


extrovertive

Recommended Posts

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?
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.com/article/image-resizing-php

All it does is resize the image by dimension and not by the filesize.
That's similar to what I plan to use for my site:
[code]<?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;
  }
?>[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.