我正在开发一个
PHP网站,让用户上传图像然后让他决定图像应该如何使用jQuery – PHP整合来选择想要成为图片的区域,然后单击裁剪按钮来裁剪它和保存.
我面临的问题是,并非所有图像类型都能很好地裁剪和保存,所以我注意到它可以很容易地将图像转换为JPG,然后让用户裁剪它,因为它是一种简单的方法. JPG格式.
我怎么能这样做?
这是图像类型问题的最佳解决方案吗?
编辑:
我正在使用此代码裁剪图像,它不是以PNG格式拍摄,也仅限于3分机.
$path_parts = pathinfo("../images/DVDs/".$_POST['logo_file']);
if ($path_parts['extension'] == "png") {
$src = imagecreatefrompng("../images/DVDs/".$_POST['logo_file']);
$tmp = imagecreatetruecolor(350, 494);
imagecopyresampled($tmp, $src, 0,0,$_POST['x'],$_POST['y'],350,494,$_POST['w'],$_POST['h']);
imagepng($tmp, "../images/DVDs/$filename".'t_'.$_POST['logo_file'],100);
} else if ($path_parts['extension'] == "jpg" || $path_parts['extension'] == "jpeg") {
$src = imagecreatefromjpeg("../images/DVDs/".$_POST['logo_file']);
$tmp = imagecreatetruecolor(350, 494);
imagecopyresampled($tmp, $src, 0,0,$_POST['x'],$_POST['y'],350,494,$_POST['w'],$_POST['h']);
imagejpeg($tmp, "../images/DVDs/$filename".'t_'.$_POST['logo_file'],100);
} else if ($path_parts['extension'] == "gif") {
$src = imagecreatefromgif("../images/DVDs/".$_POST['logo_file']);
$tmp = imagecreatetruecolor(350, 494);
imagecopyresampled($tmp, $src, 0,0,$_POST['x'],$_POST['y'],350,494,$_POST['w'],$_POST['h']);
imagegif($tmp, "../images/DVDs/$filename".'t_'.$_POST['logo_file'],100);
}
我想将图像转换为JPG格式,因为它最容易转换而没有任何问题.