Random Post: phpResource :: Go Ahead
RSS .92| RSS 2.0| ATOM 0.3
  • Home
  • About Me
  • My Publications
  • My Work Domain
  • phpResource Feeds
  •  

    See My Simple Image Thumbnailer

    Last week when I noticed the MYRUET members could not upload proper sized image to their profile page, I prepared a simple image thumbnailer. I donno if it helped them a lot but I noticed few members used it. Here is the demo:

    http://www.rupom.com/myruet/

    It is very simple one to prepare. It manipulates the would-be scale size using this formula:

    ——————————————————–

    function imageScale($image, $newWidth, $newHeight)
    {

    if(!$size = @getimagesize($image))
    {
    die("Unable to get info on image $image");
    }

    $ratio = ($size[0] / $size[1]);

    if($newWidth == -1)
    {
    $ret[1] = $newHeight;
    $ret[0] = round(($newHeight * $ratio));
    }
    else if($newHeight == -1)
    {
    $ret[0] = $newWidth;
    $ret[1] = round(($newWidth / $ratio));

    }
    else
    {
    die("Scale Error");
    }

    return $ret;
    }

    —————————————————

    Please check the thumbnailer and let me know if some changes can make this more strong.

    Best regards.

    Rupom

    Leave a Reply

    You must be logged in to post a comment.