تغيير اندازه عكس

BeHnAm_akb

Active Member
با پي اچ پي چه زور ميشه اندازه يك عكس رو تغيير داد

عكس رو قرار نيست ما توليد كنيم و عكس آپلود ميشه
 

golden

Member
اینو تو manual پیدا کردم:
PHP:
<?php

include 'mogrify.php';

// variables from flash (my website uses flash and php)
$picture="sample.jpg";
$fixedwidth=300;
$fixedheight=240;
//

cropimage($picture,$fixedwidth,$fixedheight,$mogrify);

 ?>

MOGRIFY.PHP

<?php
// walking the path
$mogrify="C:/apache/Imagik/mogrify.exe";

// ---------------------------------------- crop function

function cropimage($picture,$fixedwidth,$fixedheight,$mogrify) {

   // GET IMG
   $img = imagecreatefromjpeg($picture);
   $width= imagesx($img);
   $height= imagesy($img);
   // CROP WIDTH
   if($width!=$fixedwidth){
       $ratio =$fixedwidth/$width;
       $NewHeight=round($height*$ratio);
       $NewWidth=round($width*$ratio);
       exec( $mogrify." -resize ".$NewWidth."x".$NewHeight."! $picture");
       exec( $mogrify." -crop ".$fixedwidth."x".$fixedheight."+0+0 $picture");
       // REFRESH
       $img = imagecreatefromjpeg($picture);
       $width= imagesx($img);
       $height= imagesy($img);
   }
   // CROP HEIGHT
   if($height!=$fixedheight){
       $ratio =$fixedheight/$height;
       $NewHeight=round($height*$ratio);
       $NewWidth=round($width*$ratio);
       exec( $mogrify." -resize ".$NewWidth."x".$NewHeight."! $picture");
       exec( $mogrify." -crop ".$fixedwidth."x".$fixedheight."+0+0 $picture");
   }
   //
   ImageDestroy($img);
}

?>
 

جدیدترین ارسال ها

بالا