当前位置: 首页>>代码示例>>PHP>>正文


PHP Varien_Image_Adapter::factory方法代码示例

本文整理汇总了PHP中Varien_Image_Adapter::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Image_Adapter::factory方法的具体用法?PHP Varien_Image_Adapter::factory怎么用?PHP Varien_Image_Adapter::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Varien_Image_Adapter的用法示例。


在下文中一共展示了Varien_Image_Adapter::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: resizeFile

 /**
  * Create thumbnail for image and save it to thumbnails directory
  *
  * @param string $source Image path to be resized
  * @param bool $keepRation Keep aspect ratio or not
  * @return bool|string Resized filepath or false if errors were occurred
  */
 public function resizeFile($source, $keepRatio = true)
 {
     if (!Mage::helper('uaudio_storage')->isEnabled()) {
         return parent::resizeFile($source, $keepRatio);
     }
     if (!$this->_getStorageModel()->fileExists($source)) {
         return false;
     }
     try {
         $targetFile = str_replace('//', '/', $this->getThumbsPath($source)) . DS . pathinfo($source, PATHINFO_BASENAME);
         if (!$this->_getStorageModel()->fileExists($targetFile)) {
             $tmpName = $this->_getStorageModel()->copyFileToTmp($source);
             $image = Varien_Image_Adapter::factory('GD2');
             $image->open($tmpName);
             $width = $this->getConfigData('resize_width');
             $height = $this->getConfigData('resize_height');
             $image->keepAspectRatio($keepRatio);
             $image->resize($width, $height);
             $image->save($tmpName);
             $dest = $this->_getStorageModel()->moveFile($tmpName, $targetFile);
             return $dest;
         } else {
             return $this->_getStorageModel()->getRelativeDestination($targetFile);
         }
     } catch (Exception $e) {
         Mage::logException($e);
         return false;
     }
 }
开发者ID:uaudio,项目名称:magento-filestorage,代码行数:36,代码来源:Storage.php

示例2: resizeImg

 public function resizeImg($fileName, $width, $height = null)
 {
     //$fileName = 'slideshow\slides\\'.$fileName;
     $folderURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
     $imageURL = $folderURL . $fileName;
     $basePath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . 'slideshow' . DS . 'slides' . DS . $fileName;
     $newPath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . 'slideshow' . DS . 'slides' . DS . 'thumbs' . DS . $fileName;
     //if width empty then return original size image's URL
     if ($width != '') {
         //if image has already resized then just return URL
         if (file_exists($basePath) && is_file($basePath) && !file_exists($newPath)) {
             $imageObj = Varien_Image_Adapter::factory('GD2');
             $imageObj->constrainOnly(true);
             $imageObj->keepAspectRatio(true);
             $imageObj->keepFrame(true);
             $imageObj->backgroundColor(array(255, 255, 255));
             $imageObj->open($basePath);
             $imageObj->resize($width, $height);
             $imageObj->save($newPath);
         }
         $resizedURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'resized' . DS . $fileName;
     } else {
         $resizedURL = $imageURL;
     }
     return $resizedURL;
 }
开发者ID:remiebeling,项目名称:MageProfis_Slideshow,代码行数:26,代码来源:Data.php

示例3: directiveAction

 /**
  * Template directives callback
  *
  * TODO: move this to some model
  */
 public function directiveAction()
 {
     $directive = $this->getRequest()->getParam('___directive');
     $directive = Mage::helper('core')->urlDecode($directive);
     $url = Mage::getModel('cms/adminhtml_template_filter')->filter($directive);
     try {
         $image = Varien_Image_Adapter::factory('GD2');
         $image->open($url);
         $image->display();
     } catch (Exception $e) {
         $image = Varien_Image_Adapter::factory('GD2');
         $image->open(Mage::getSingleton('cms/wysiwyg_config')->getSkinImagePlaceholderPath());
         $image->display();
         /*
         $image = imagecreate(100, 100);
         $bkgrColor = imagecolorallocate($image,10,10,10);
         imagefill($image,0,0,$bkgrColor);
         $textColor = imagecolorallocate($image,255,255,255);
         imagestring($image, 4, 10, 10, 'Skin image', $textColor);
         header('Content-type: image/png');
         imagepng($image);
         imagedestroy($image);
         */
     }
 }
开发者ID:quyip8818,项目名称:Mag,代码行数:30,代码来源:WysiwygController.php

示例4: _beforeSave

 /**
  * Checks if choosen image adapter available
  *
  * @throws Mage_Core_Exception if some of adapter dipendencies was not loaded
  * @return Mage_Adminhtml_Model_System_Config_Backend_File
  */
 protected function _beforeSave()
 {
     $value = $this->getValue();
     $adapter = Varien_Image_Adapter::factory($value);
     try {
         $adapter->checkDependencies();
     } catch (Exception $e) {
         $message = Mage::helper('Mage_Core_Helper_Data')->__('The specified image adapter cannot be used because of some missed dependencies.');
         throw new Mage_Core_Exception($message);
     }
     return $this;
 }
开发者ID:nemphys,项目名称:magento2,代码行数:18,代码来源:Adapter.php

示例5: directiveAction

 /**
  * Template directives callback
  *
  * TODO: move this to some model
  */
 public function directiveAction()
 {
     $directive = $this->getRequest()->getParam('___directive');
     $directive = Mage::helper('core')->urlDecode($directive);
     $url = Mage::getModel('cms/adminhtml_template_filter')->filter($directive);
     try {
         $image = Varien_Image_Adapter::factory('GD2');
         $image->open($url);
         $image->display();
     } catch (Exception $e) {
         $image = Varien_Image_Adapter::factory('GD2');
         $image->open(Mage::getSingleton('cms/wysiwyg_config')->getSkinImagePlaceholderPath());
         $image->display();
     }
 }
开发者ID:ramantalkin,项目名称:tmp01skin,代码行数:20,代码来源:WysiwygController.php

示例6: directiveAction

 public function directiveAction()
 {
     $directive = $this->getRequest()->getParam("___directive");
     $directive = Mage::helper("core")->urlDecode($directive);
     $url = Mage::getModel("core/email_template_filter")->filter($directive);
     try {
         $image = Varien_Image_Adapter::factory("GD2");
         $image->open($url);
         $image->display();
     } catch (Exception $e) {
         $image = Varien_Image_Adapter::factory("GD2");
         $image->open(Mage::getSingleton("cms/wysiwyg_config")->getSkinImagePlaceholderUrl());
         $image->display();
     }
 }
开发者ID:sshegde123,项目名称:wmp8,代码行数:15,代码来源:ImageController.php

示例7: directiveAction

 /**
  * Template directives callback
  *
  * TODO: move this to some model
  */
 public function directiveAction()
 {
     $directive = $this->getRequest()->getParam('___directive');
     $directive = Mage::helper('Mage_Core_Helper_Data')->urlDecode($directive);
     $url = Mage::getModel('Mage_Core_Model_Email_Template_Filter')->filter($directive);
     $adapter = Mage::helper('Mage_Core_Helper_Data')->getImageAdapterType();
     $image = Varien_Image_Adapter::factory($adapter);
     $response = $this->getResponse();
     try {
         $image->open($url);
         $response->setHeader('Content-Type', $image->getMimeType())->setBody($image->getImage());
     } catch (Exception $e) {
         $image->open(Mage::getSingleton('Mage_Cms_Model_Wysiwyg_Config')->getSkinImagePlaceholderUrl());
         $response->setHeader('Content-Type', $image->getMimeType())->setBody($image->getImage());
         Mage::logException($e);
     }
 }
开发者ID:nemphys,项目名称:magento2,代码行数:22,代码来源:WysiwygController.php

示例8: directiveAction

 public function directiveAction()
 {
     if (!Mage::helper('uaudio_storage')->isEnabled()) {
         return parent::directiveAction();
     }
     $storageModel = Mage::getSingleton('core/file_storage')->getStorageModel();
     $directive = $this->getRequest()->getParam('___directive');
     $directive = Mage::helper('core')->urlDecode($directive);
     $url = Mage::getModel('cms/adminhtml_template_filter')->filter($directive);
     if ($storageModel->fileExists($url)) {
         $url = ltrim(str_replace(Mage::getBaseDir('media'), '', $url), '/');
         $this->getResponse()->setRedirect(Mage::getBaseUrl('media') . $url);
     } else {
         $image = Varien_Image_Adapter::factory('GD2');
         $image->open(Mage::getSingleton('cms/wysiwyg_config')->getSkinImagePlaceholderPath());
         $image->display();
     }
 }
开发者ID:uaudio,项目名称:magento-filestorage,代码行数:18,代码来源:WysiwygController.php

示例9: _resizeImage

 /**
  * Resize image and create cached file with the new size.
  *
  * @param $source
  * @param $width
  * @param $height
  * @param bool $keep_ration
  * @return bool|string
  */
 private function _resizeImage($source, $width, $height, $keep_ration = true)
 {
     $path_media = Mage::getBaseDir('media');
     if (!is_file($path_media . $source) || !is_readable($path_media . $source)) {
         return false;
     }
     $path_image = Mage::app()->getStore()->getConfig('slider/options/folder');
     $path_cache = $path_media . $path_image . DS . 'cache' . DS . $width . 'x' . $height;
     $this->checkFolderExists($path_cache);
     $image = Varien_Image_Adapter::factory('GD2');
     $image->open($path_media . $source);
     $image->keepAspectRatio($keep_ration);
     $image->resize($width, $height);
     $_destination = $path_cache . DS . pathinfo($source, PATHINFO_BASENAME);
     $image->save($_destination);
     if (is_file($_destination)) {
         return $_destination;
     }
     return false;
 }
开发者ID:robinbortlik,项目名称:magento-dc-slider,代码行数:29,代码来源:Image.php

示例10: _getAdapter

 /**
  * Retrieve image adapter object
  *
  * @param string $adapter
  * @return Varien_Image_Adapter_Abstract
  */
 protected function _getAdapter($adapter = null)
 {
     if (!isset($this->_adapter)) {
         $this->_adapter = Varien_Image_Adapter::factory($adapter);
     }
     return $this->_adapter;
 }
开发者ID:evinw,项目名称:project_bloom_magento,代码行数:13,代码来源:Image.php

示例11: thumbnailAction

 /**
  * Generate image thumbnail on the fly
  */
 public function thumbnailAction()
 {
     $file = $this->getRequest()->getParam('file');
     $file = Mage::helper('cms/wysiwyg_images')->idDecode($file);
     $thumb = $this->getStorage()->resizeOnTheFly($file);
     if ($thumb !== false) {
         $image = Varien_Image_Adapter::factory('GD2');
         $image->open($thumb);
         $image->display();
     } else {
         // todo: genearte some placeholder
     }
 }
开发者ID:cnglobal-sl,项目名称:caterez,代码行数:16,代码来源:ImagesController.php

示例12: resizeFile

 /**
  * Create thumbnail for image and save it to thumbnails directory
  *
  * @param string $source Image path to be resized
  * @param bool $keepRation Keep aspect ratio or not
  * @return bool|string Resized filepath or false if errors were occurred
  */
 public function resizeFile($source, $keepRation = true)
 {
     if (!is_file($source) || !is_readable($source)) {
         return false;
     }
     $targetDir = $this->getThumbsPath($source);
     $io = new Varien_Io_File();
     if (!$io->isWriteable($targetDir)) {
         $io->mkdir($targetDir);
     }
     if (!$io->isWriteable($targetDir)) {
         return false;
     }
     $image = Varien_Image_Adapter::factory('GD2');
     $image->open($source);
     $width = $this->getConfigData('resize_width');
     $height = $this->getConfigData('resize_height');
     $image->keepAspectRatio($keepRation);
     $image->resize($width, $height);
     $dest = $targetDir . DS . pathinfo($source, PATHINFO_BASENAME);
     $image->save($dest);
     if (is_file($dest)) {
         return $dest;
     }
     return false;
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:33,代码来源:Storage.php

示例13: thumbnailAction

 /**
  * Generate image thumbnail on the fly
  */
 public function thumbnailAction()
 {
     $file = $this->getRequest()->getParam('file');
     $file = Mage::helper('Mage_Cms_Helper_Wysiwyg_Images')->idDecode($file);
     $thumb = $this->getStorage()->resizeOnTheFly($file);
     if ($thumb !== false) {
         $adapter = Mage::helper('Mage_Core_Helper_Data')->getImageAdapterType();
         $image = Varien_Image_Adapter::factory($adapter);
         $image->open($thumb);
         $this->getResponse()->setHeader('Content-Type', $image->getMimeType())->setBody($image->getImage());
     } else {
         // todo: genearte some placeholder
     }
 }
开发者ID:natxetee,项目名称:magento2,代码行数:17,代码来源:ImagesController.php

示例14: resizeFile

 /**
  * Create thumbnail for image and save it to thumbnails directory
  *
  * @param string $source Image path to be resized
  * @param bool $keepRation Keep aspect ratio or not
  * @return bool|string Resized filepath or false if errors were occurred
  */
 public function resizeFile($source, $keepRation = true)
 {
     if (!$this->_filesystem->isFile($source) || !$this->_filesystem->isReadable($source)) {
         return false;
     }
     $targetDir = $this->getThumbsPath($source);
     if (!$this->_filesystem->isWritable($targetDir)) {
         $this->_filesystem->createDirectory($targetDir);
     }
     if (!$this->_filesystem->isWritable($targetDir)) {
         return false;
     }
     $adapter = Mage::helper('Mage_Core_Helper_Data')->getImageAdapterType();
     $image = Varien_Image_Adapter::factory($adapter);
     $image->open($source);
     $width = $this->getConfigData('resize_width');
     $height = $this->getConfigData('resize_height');
     $image->keepAspectRatio($keepRation);
     $image->resize($width, $height);
     $dest = $targetDir . DS . pathinfo($source, PATHINFO_BASENAME);
     $image->save($dest);
     if ($this->_filesystem->isFile($dest)) {
         return $dest;
     }
     return false;
 }
开发者ID:natxetee,项目名称:magento2,代码行数:33,代码来源:Storage.php

示例15: getImageAdapter

 /**
  * @param $value
  * @return Varien_Image_Adapter_Gd2|Varien_Image_Adapter_Imagemagic|Varien_Image_Adapter_ImagemagicExternal
  */
 public function getImageAdapter($value)
 {
     return Varien_Image_Adapter::factory($value);
 }
开发者ID:sergeykalenyuk,项目名称:Perfect_Watermarks,代码行数:8,代码来源:Data.php


注:本文中的Varien_Image_Adapter::factory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。