博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
magento----已经存在的图片地址,生成自定义尺寸的图片
阅读量:4200 次
发布时间:2019-05-26

本文共 932 字,大约阅读时间需要 3 分钟。

根据已经存在的图片地址,生成自定义尺寸的图片。。

处理图片的类是: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"));
    }

转载地址:http://xwcli.baihongyu.com/

你可能感兴趣的文章
论文浅尝 | GMNN: Graph Markov Neural Networks
查看>>
应用实践 | 网络智能运维下的知识图谱
查看>>
应用实践 | 南方科技大学研发基于新型冠状病毒知识图谱模式挖掘系统
查看>>
征稿 | 2020年全国知识图谱与语义计算大会
查看>>
论文浅尝 - CIKM2020 | Relation Reflection Entity Alignment
查看>>
论文浅尝 - WWW2020 | 通过对抗学习从用户—项目交互数据中挖掘隐含的实体偏好来用于知识图谱补全任务...
查看>>
论文浅尝 - AAAI2021 | 从历史中学习:利用时间感知拷贝生成网络建模时态知识图谱...
查看>>
论文浅尝 - EMNLP | 通过元强化学习实现少样本复杂知识库问答
查看>>
论文浅尝 | 利用跨内和跨间信息的预训练实体关系编码器
查看>>
论文浅尝 | S3QLRDF: 用于大规模RDF数据分布式SPARQL查询的关系分割架构
查看>>
论文浅尝 - ICLR2021 | BERTology 遇上生物学:在蛋白质语言模型中解释注意力
查看>>
论文浅尝 | BoxE:一种基于Box的知识图谱表示学习模型
查看>>
论文小综 | Attention in Graph Neural Networks
查看>>
技术动态 | 不确定性知识图谱的表示和推理
查看>>
论文浅尝 - ECIR2021 | 两种实体对齐方法的严格评估
查看>>
论文浅尝 | 用于嵌套命名实体识别的二部平面图网络(BiFlaG)
查看>>
会议交流 | 智能风控技术峰会(请关注图分析相关论坛)
查看>>
开源开放 | 欢迎选修浙江大学《知识图谱》开放共享慕课
查看>>
征稿 | Call for papers on Knowledge Graphs
查看>>
论文浅尝 | 当Hearst还不够时:用分布模型来提升语料库中的上下义关系检测
查看>>