没关系,我找到了解决方案.我创建了一个带帮助程序的自定义模块,其中包含来自第三方脚本Zebra Image
http://stefangabos.ro/php-libraries/zebra-image/的函数
这是我创建的Helper文件夹中的Data.php文件:
class yokubo_customContent_Helper_Data extends Mage_Core_Helper_Abstract{
public function resize($img,$target) {
$ExternalLibPath=Mage::getModuleDir('lib', 'yokubo_customContent'). DS . 'lib' . DS .'Zebra_Image.php';
require_once ($ExternalLibPath);
$image = new Zebra_Image();
$image->source_path = $img;
$image->target_path = $target;
$image->jpeg_quality = 100;
$image->preserve_aspect_ratio = true;
$image->enlarge_smaller_images = true;
$image->preserve_time = true;
$image->resize(300, 300, ZEBRA_IMAGE_CROP_CENTER);
}
我现在可以通过指定图像的路径和目标目录来为任何图像执行任务:Mage :: helper(‘customContent’) – > resize($_ imageUrl,$imageResized);