什么可以导致JPEG图像损坏,用PHP中的Imagick创建?

时间:2015-03-02 22:11:58

标签: php jpeg imagick

最近我开始遇到PHP生成图像的麻烦。看看这张图片:http://video.advisor.travel/960x545px-video_60.jpg

如您所见,此图片已损坏。使用Imagick模块生成图像,重新调整源图像(在这种情况下为岛屿和海洋),并将其与" Play"图标。然后使用INTERLACE_PLANE选项(简化)将图像保存到磁盘:

$this->image = new Imagick ();
$this->image->readImage($origFileName);
$this->image->resizeImage($width, $height, Imagick::FILTER_CATROM, $this->blur);
$this->image->contrastImage(1);
$this->image->sharpenImage(0.8, 0.5);

$centered_left = $this->width / 2 - self::ICON_WIDTH / 2;
$centered_top = $this->height / 2 - self::ICON_WIDTH / 2;
$play_icon = new Imagick ();
$this->image->readImage($play_icon);

// Combine image and play icon
$this->image->compositeImage($play_icon, Imagick::COMPOSITE_DEFAULT, $centered_left, $centered_top, Imagick::CHANNEL_ALL);

// Remove meta-data
$this->image->stripimage();

// Compress
$this->image->setImageCompression(Imagick::COMPRESSION_JPEG);
$this->image->setInterlaceScheme(Imagick::INTERLACE_PLANE);
$this->image->setImageCompressionQuality(90);

// Write to disk
$this->image->writeImage($destFileName);

由于大多数图像都能正常工作,所以我不知道是怎么回事,图像尺寸的变化很小(例如,http://video.advisor.travel/960x544px-video_60.jpg,只需1个像素)将会(或不会:)好的。

系统运行在Ubuntu 14.04,PHP 5.5.20,imagick模块版本3.1.2,ImageMagick版本6.6.9-7 2014-03-06 Q16。

为什么会发生这种情况的任何想法,或者我如何能够检测到代码在代码中被破坏,我们将非常感激!

0 个答案:

没有答案