修改Magento 支持ImageMagick

Magento uses a GD2 library function called imagejpeg() to cache your product images. Unfortunately, the imagejpeg() function will always cause a slight degradation in image quality (yes, even if you specify 100% quality).

If you need razor sharp, crystal clear images for your store like I did (selling artwork), here’s a solution for you.

Step One: Install ImageMagick on your server (some hosts already have this installed).

Step Two: Install the IMagick pecl php extension.

Note: Directions for step one and step two: http://valokuva.org/?page_id=50

Step Three: Copy lib/Varien/Image/Adapter/Gd2.php to app/code/local/Varien/Image/Adapter/Gd2.php

mkdir -p app/code/local/Varien/Image/Adapter
cp lib/Varien/Image/Adapter/Gd2.php app/code/local/Varien/Image/Adapter

Step Four: In the Gd2.php file, in the save() function comment out

call_user_func_array($this->_getCallback("output"), $functionParameters);

This is the where Magento calls the imagejpeg() function. Yuck.
Now add the following code just below the commented out line.

$source_file = $this->_fileSrcPath. "/".$this->_fileSrcName;
$image_info = getimagesize($source_file);
$im = new Imagick();
$im->readImage($source_file);

//check to see if image needs to be resized (eg. thumbnails)
if ($image_info[0] != $this->_imageSrcWidth) {
     $im->thumbnailImage($this->_imageSrcWidth, $this->_imageSrcHeight);
}
$im->writeImage($fileName);

That’s it! This will create razor sharp product images and thumbnails.

Refrence: http://www.magentocommerce.com/boards/viewreply/299873/

PHP imagick-3.1.0RC2无法安装,提示fatal error: wand/MagickWand.h: No such file or directory 解决方法

PHP安装imagick-3.1.0RC2时提示:

an error occur: fatal error: wand/MagickWand.h: No such file or directory

解决办法:
1.确认已安装 ImageMagick
2.安装pkgconfig

yum install gtk+-devel
export PKG_CONFIG_PATH=/usr/local/ImageMagick/lib/pkgconfig/

确认ImageMagick 的安装目录是这个目录

3.重新安装PHP扩展:imagick
http://pecl.php.net/package/imagick

wget -c http://pecl.php.net/get/imagick-3.2.0RC1.tgz
tar zxvf imagick-3.2.0RC1.tgz
cd imagick-3.2.0RC1/
make clean
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-imagick=/usr/local/ImageMagick
make && make install
ldconfig -v /usr/local/

4. 配置使PHP加载imagick 扩展

vi /usr/local/php/etc/php.ini

#搜索 extension_dir, PHP 5.3.x中 extension_dir 的默认值一般设置成
#/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
添加一行记录

extension = "imagick.so"
#按键盘 ESC 键 退出编辑状态
:wq #保存退出

重启PHP, lnmpa 环境下,重启 Apache 即可

service httpd -k restart

附 ImageMagick,imagick 下载地址

ImageMagick http://www.imagemagick.org/script/download.php
imagick-3.2.0RC1 最新版下载 http://pecl.php.net/package/imagick

ImageMagick 安装教程:

wget -c ftp://ftp.kddlabs.co.jp/graphics/ImageMagick/ImageMagick-6.8.8-1.tar.gz
tar zxvf ImageMagick-6.8.8-1.tar.gz
cd ImageMagick-6.8.8-1/
./configure --prefix=/usr/local/ImageMagick/
make
make install
cd ../

测试是否安装成功

/usr/local/ImageMagick/bin/convert logo: logo.gif

如果没有提示任何错误,然后检查执行命令时所在的目录 看看是否生成了 logo.gif 这个文件

ll logo.gif

查看ImageMagick 版本及配置参数

/usr/local/ImageMagick/bin/identify -list configure

附录,linux下查看磁盘的剩余空间

df -lh

本文部分内容参考 http://www.g78.net/?p=288 在此感谢