title: php how to crop image then stretch to prevent black bar
body: <p>i looking for solution of crop images to square but the result have issue with black bar on both side if the image's ratio to0 big.</p>
  
  <pre><code>eg:
  croped
  http://static.xaluan.com/images/news/Image/2013/11/13/med_15282b4691c7e6.img.jpg
  original
  http://static.xaluan.com/images/news/Image/2013/11/1315282b4691c7e6.img.jpg
  </code></pre>
  
  <p>I have tried with solution of filling that blackbar with other color but result not really nice.</p>
  
  <p>So i thinking of after crop the images need to be stretching a bit in thumble so people not notice of changing of images in thumbles but the blackbar will go away will be nice.
  Please help to work this out
  thanks
  following my code:</p>
  
  <pre><code>            $src_width= ImagesX($src_img);
              $src_height= ImagesY($src_img);
              $dest_width = $insize;
              $dest_height = $src_height/($src_width/$dest_width);
              if ( $cropYes == 1){
                         if($src_width &gt; $src_height) $biggestSide = $src_width; //find biggest length
                         else $biggestSide = $src_height; 
                         $cropPercent = .7; // This will zoom in to 70% zoom (crop)
                         $cropWidth   = $biggestSide*$cropPercent; 
                         $cropHeight  = $biggestSide*$cropPercent; 
                         $xcrop = ($src_width-$cropWidth)/2;
                         if ($src_width &gt;= $src_height){
                         $ycrop = ($src_height-$cropHeight)/2;  //use this if need from center
                         } else {$ycrop = 0; }//set crop from top images
              $dest_img = ImageCreateTrueColor($dest_width, $dest_width);
              ImageCopyResampled($dest_img, $src_img, 0, 0, $xcrop, $ycrop, $dest_width, $dest_width, $cropWidth, $cropHeight); 
  //          $white = imagecolorallocate($dest_img, 255, 255, 255);
  //          imagefill($dest_img, 0, 0, $white); // set backgound to white
  </code></pre>