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?
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.