нормально, а если в цикле - нет, отрабатывается только последняя итерация.
                  
                  
                  
                  
                  
                  <? function MakeSquarePict($url_identificator, $source_origin) {    
                  
                  
                  
                  
                  
                          header("Content-type: image/png");
                  
                  
                  
                  
                  
                          $img_saved_url = 'temp/'.$url_identificator.'.png';
                  
                  
                  
                  
                  
                          $size = getimagesize($source_origin);
                  
                  
                          $format = strtolower(substr($size['mime'], strpos($size['mime'], '/')+1));
                  
                  
                          $icfunc = "imagecreatefrom" . $format;
                  
                  
                  
                  
                  
                          if (!function_exists($icfunc)) return false;
                  
                  
                          $temp_img = $icfunc($source_origin);
                  
                  
                  
                  
                  
                          $temp_img = imagecropauto($temp_img, IMG_CROP_THRESHOLD, null, 16777215);
                  
                  
                  
                  
                  
                          $rgb=0xffffff;
                  
                  
                          $size[0] = imagesx($temp_img);
                  
                  
                          $size[1] = imagesy($temp_img);
                  
                  
                  
                  
                  
                          if ($size[0] > $size[1]) {
                  
                  
                            $width=$size[0];
                  
                  
                            $height=$size[0];
                  
                  
                          } else {  
                  
                  
                            $width=$size[1];
                  
                  
                            $height=$size[1];
                  
                  
                          }
                  
                  
                  
                  
                  
                          $x_ratio = $width / $size[0]; 
                  
                  
                          $y_ratio = $height / $size[1]; 
                  
                  
                          $ratio       = min($x_ratio, $y_ratio);
                  
                  
                          $use_x_ratio = ($x_ratio == $ratio); 
                  
                  
                          $new_width   = $use_x_ratio  ? $width  : floor($size[0] * $ratio);
                  
                  
                          $new_height  = !$use_x_ratio ? $height : floor($size[1] * $ratio); 
                  
                  
                          $new_left    = $use_x_ratio  ? 0 : floor(($width - $new_width) / 2);
                  
                  
                          $new_top     = !$use_x_ratio ? 0 : floor(($height - $new_height) / 2); 
                  
                  
                          $img = imagecreatetruecolor($width,$height);
                  
                  
                          imagefill($img, 0, 0, $rgb);
                  
                  
                  
                  
                  
                          $img_small = imagecreatetruecolor(300,300);
                  
                  
                          imagefill($img_small, 0, 0, $rgb);
                  
                  
                  
                  
                  
                          imagecopyresampled($img, $temp_img, $new_left, $new_top, 0, 0, $new_width, $new_height, $size[0], $size[1]); 
                  
                  
                  
                  
                  
                          imagepng($img, $img_saved_url); 
                  
                  
                  
                  
                  
                          imagedestroy($img);
                  
                  
                          imagedestroy($img_small);
                  
                  
                          imagedestroy($photo);
                  
                  
                  
                  
                  
                  }
                  
                  
                
мамочки, можно пастебин или что-то такое
ты нам не коллега
Обсуждают сегодня