magento----已经存在的图片地址,生成自定义尺寸的图片
来源:互联网 发布:用友软件下载免费版 编辑:程序博客网 时间:2024/06/07 12:24
根据已经存在的图片地址,生成自定义尺寸的图片。。
处理图片的类是:lib/Varien/Image.php。
public function getThumbnailResize($width, $height = null) {
// actual path of image
$imageUrl = Mage::getBaseDir('media').DS.$this->getData("thumbnail");
// path of the resized image to be saved
// here, the resized image is saved in media/resized folder
$imageResized = Mage::getBaseDir('media').DS."resized_".$this->getData("thumbnail");
// resize image only if the image file exists and the resized image file doesn't exist
// the image is resized proportionally with the width/height 135px
if (!file_exists($imageResized)&&file_exists($imageUrl)) {
$imageObj = new Varien_Image($imageUrl);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(TRUE);
$imageObj->keepFrame(FALSE);
////////////////////////////////////////////////////////////////////////////
$imageObj->resize($width, $height);
$imageObj->save($imageResized);
}
return (Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . "media/" . "resized_".$this->getData("thumbnail"));
}
- magento----已经存在的图片地址,生成自定义尺寸的图片
- jmacick生成不同尺寸图片的应用
- 一个已经存在的CCSprite怎么替换新的图片
- 调整图片的尺寸
- watch图片的尺寸
- Nginx+Lua+GraphicsMagick实现动态生成指定尺寸的图片
- PHP生成IP地址图片的代码
- magento ---垃圾图片的处理
- 让Magento生成的PDF打印图片(Magento invoice shipment pdf add product images)
- 上传图片前判断图片的尺寸
- 上传图片前判断图片的尺寸
- 限制上传图片的尺寸
- GetImageSize获取图片的尺寸
- 获取网络图片的尺寸
- 限制图片显示的尺寸
- Apache 文件不存在跳转URL(实现指定尺寸的图片不存在,就自动生成图片)
- js根据图片路径地址判断图片是否存在的几种方法
- magento删除重复图片,后台图片传2次之后重复,magento图片的存储见解
- 找CMS
- WebResource实现在自定义控件中内嵌JS文件和样式文件
- 去掉鼠标点击后的虚线边框
- 数据库中数据导出成excel
- 推荐几个Google Sitemap工具
- magento----已经存在的图片地址,生成自定义尺寸的图片
- git配置global信息
- VS调试JavaScript脚本
- div 设置隐藏后,如何不让它占位
- 用 Dialplan 实现IVR交互
- 通过崩溃地址找出源代码的出错行
- 新年新计划
- 备份sources.list
- Cstring转char、string、int等数据类型的方法