Magento Image processing extension
Is there any extension which is specifically goes for fill image color like module. I have 1000's of images which all sa开发者_StackOverflow中文版me size but have white space around all image, instead of using photoshop can i use PHP to process that image to have different(brown color - sine it is background) instead of white. If there is any extension please suggest me.
Thanks in advance
If you want to have same background for all images,you can override the magento class that applies background color.
File is app/code/core/Mage/Catalog/Model/Product/Image.php
Find the code that looks like this protected $_backgroundColor = array(255, 255, 255);
and specify the RGB value of the colour that you want.
Check out ImageMagick. I haven't used it for exactly what you are trying to do, but I have used it for other kinds of batch image processing. It can be ran from the commandline, but also has APIs for several programming languages.
For what you are trying to do, I'd take a look at the -fill, -floodfill, and -fuzz options. http://www.imagemagick.org/script/command-line-options.php#fill
I got solution for my problem by the following method.
<?php
echo $this->helper('catalog/image')->init($_product, 'image')
->constrainOnly(TRUE)
->keepAspectRatio(TRUE)
->keepFrame(FALSE)
->resize(600,null)
?>
I got it from here.
http://blog.chapagain.com.np/magento-resize-image/
You should consider getting rid of that white space unless you have other reason for it, e.g. to have product images to scale.
This is best achieved with Photoshop if you have got it, if the white is absolutely, definitely white then you can take the top-left pixel and crop from that.
Another option you may wish to consider is using png images, again this depends on your images and skill in Photoshop, however, you can use transparency in png and have no border on your images.
Also, in photoshop or imagemagick you may want to consider making your own thumbnail images, separate to the product page image. This will enable you to apply filters such as sharpen to get product page images that are a cut above your competitors.
As noted by @jmspldnl you can use imagemagick on the command line as well as php extension. On the command line you can work out the process and string together lots of steps, when happy with your options, rather than re-work it in php code you can use 'passthru()' and run what you worked out from the command line.
For going forward you can put a cron job that monitors your images folder and processes and images that have been changed/added in the last day. This will make it easier to just upload images and have your system do the work.
精彩评论