static function cut($pic, $dst_pic, $width, $height = null, $qulitity = 100)
{
$im = imagecreatefromjpeg($pic);
if (imagesx($im) > $width) {
$old_w = imagesx($im);
$old_h = imagesy($im);
if ($height == null) {
$w_h = $old_w / $old_h;
$height = $width * $w_h;
}
$newim = imagecreatetruecolor($width, $height);
imagecopyresampled($newim, $im, 0, 0, 0, 0, $width, $height, $old_w, $old_h);
imagejpeg($newim, $dst_pic, $qulitity);
imagedestroy($im);
return true;
} elseif ($pic != $dst_pic) {
return copy($pic, $dst_pic);
}
return false;
}