嗨,我正在做的是抓取原始图像的大小,然后创建一个具有这些尺寸的新图像($image_p),然后旋转它。有时,尽管当我在服务器上旋转图像时,图像的边框上会出现一条黑线。顺便说一句,我正在旋转 jpeg
怎么去掉那条黑线?谢谢
.php 文件
$angle = (Input::get('angle') * -1);
$width = getimagesize($new_temp_image_filepath)[0];
$height = getimagesize($new_temp_image_filepath)[1];
$image_p = imagecreatetruecolor($width, $height);
//grab temporary file
$src_imgbinary = File::get($new_temp_image_filepath);
//turn temp file string into image resource
$src_image = imagecreatefromstring($src_imgbinary);
imagecopyresampled($image_p, $src_image, 0, 0, 0, 0, $width, $height, $width, $height);
$rotated_image = imagerotate($image_p, $angle, 0);
//create image file based on extension and replace existing file in temp folder
$image_ext = exif_imagetype($new_temp_image_filepath);
if ($image_ext == IMAGETYPE_GIF) {
imagegif($rotated_image, $new_temp_image_filepath);
} elseif ($image_ext == IMAGETYPE_PNG) {
imagepng($rotated_image, $new_temp_image_filepath, 0);
} else {
imagejpeg($rotated_image, $new_temp_image_filepath, 100);
}