завивать и изменять размер удаленного изображения

Я использую этот скрипт для загрузки и изменения размера удаленного изображения. В области изменения размера что-то идет не так. Что это?

<?php $img[]='http://img.ruphp.com/php/thumb1.jpg'; $img[]='http://img.ruphp.com/php/thumb5.jpg'; foreach($img as $i){ save_image($i); if(getimagesize(basename($i))){ echo '<h3 style="color: green;">Image ' . basename($i) . ' Downloaded OK</h3>'; }else{ echo '<h3 style="color: red;">Image ' . basename($i) . ' Download Failed</h3>'; } } function save_image($img,$fullpath='basename'){ if($fullpath=='basename'){ $fullpath = basename($img); } $ch = curl_init ($img); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); $rawdata=curl_exec($ch); curl_close ($ch); // now you make an image out of it $im = imagecreatefromstring($rawdata); $x=300; $y=250; // then you create a second image, with the desired size // $x and $y are the desired dimensions $im2 = imagecreatetruecolor($x,$y); imagecopyresized($im2,$im,0,0,0,0,$x,$y,imagesx($im),imagesy($im)); imagecopyresampled($im2,$im,0,0,0,0,$x,$y,imagesx($im),imagesy($im)); // delete the original image to save resources imagedestroy($im); if(file_exists($fullpath)){ unlink($fullpath); } $fp = fopen($fullpath,'x'); fwrite($fp, $im2); fclose($fp); // remember to free resources imagedestroy($im2); } ?> 

Solutions Collecting From Web of "завивать и изменять размер удаленного изображения"