Php照片编辑导致照片上的黑线

时间:2013-10-25 02:00:38

标签: php image image-processing imagemagick gd

我正在做的是抓取原始图像的大小,然后使用这些尺寸创建一个新图像($ image_p)然后旋转它。有时虽然当我在服务器上旋转图像时,图像在边框上出现黑线。顺便说一下,我正在旋转jpegs

如何删除黑线?感谢

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);
    }

0 个答案:

没有答案