PHP Developer Hub

Discussion in 'Programming' started by web-solution, Apr 14, 2008.

  1. #1
    Hi This is dk , i am expert in php/mrsql and Ajax join this for share php

    works . and post your problem . This is only best for php Developer .

    Contact me for quality and reliable work.

    Email me :

    web.websolution at gmail .com
     
    web-solution, Apr 14, 2008 IP
  2. web-solution

    web-solution Well-Known Member

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    106
    #2
    setp 1: save this code any php file name ex: thumb.php

    function code :

    <?
    function createThumbnail($imageDirectory, $imageName, $thumbDirectory,$thumb_w,$thumb_h)
    {
    $size= getimagesize("$imageDirectory/".$imageName);
    $origHeight = $size[1];
    $origWidth = $size[0];
    $type=$size[2];
    $tsrc="thumb_".$imageName;
    if(($origHeight)>=($origWidth))
    {
    $thumbHeight =$thumb_h;
    $thumbWidth = ceil($origWidth *($thumbHeight /$origHeight) );
    }
    if(($origWidth)>=($origHeight))
    {
    $thumbWidth =$thumb_w;
    $thumbHeight = $origHeight;
    $thumbHeight = ceil( $origHeight * ($thumbWidth /$origWidth));
    }
    if($type==1) // for gif formate // //resize the image//
    {
    $im=imagecreatefromgif("$imageDirectory/".$imageName);
    $newimage=imagecreatetruecolor($thumbWidth,$thumbHeight);
    imagecopyresampled($newimage,$im,0,0,0,0,$thumbWidth,$thumbHeight,$origWidth,$origHeight);
    imagegif($newimage,"$imageDirectory/".$tsrc);
    chmod("$imageDirectory/$tsrc",0777);
    }
    if($type==2) // for jpeg formate // //resize the image//
    {
    $im=imagecreatefromjpeg("$imageDirectory/".$imageName);
    $newimage=imagecreatetruecolor($thumbWidth,$thumbHeight);
    imagecopyresampled($newimage,$im,0,0,0,0,$thumbWidth,$thumbHeight,$origWidth,$origHeight);
    imagejpeg($newimage,"$imageDirectory/".$tsrc);
    chmod("$imageDirectory/$tsrc",0777);
    }
    if($type==3) // for png formate // //resize the image//
    {
    $im=imagecreatefrompng("$imageDirectory/".$imageName);
    $newimage=imagecreatetruecolor($thumbWidth,$thumbHeight);
    imagecopyresampled($newimage,$im,0,0,0,0,$thumbWidth,$thumbHeight,$origWidth,$origHeight);
    imagepng($newimage,"$imageDirectory/".$tsrc);
    chmod("$imageDirectory/$tsrc",0777);
    }

    ?>


    step 2: include this function on the in which u want to create thumbnail


    setp3: createThumbnail('logo', $img, 'logo',50,50);
     
    web-solution, Apr 14, 2008 IP
  3. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #3
    What is mrsql ?
     
    it career, Apr 14, 2008 IP
  4. Farhan5

    Farhan5 Peon

    Messages:
    189
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    is php easy to learn???
     
    Farhan5, Apr 14, 2008 IP