本文整理汇总了PHP中Varien_Image类的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Image类的具体用法?PHP Varien_Image怎么用?PHP Varien_Image使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Varien_Image类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: saveAction
public function saveAction()
{
$data = $this->getRequest()->getPost();
if (isset($_FILES['bannerimage']['name']) and file_exists($_FILES['bannerimage']['tmp_name'])) {
try {
$uploader = new Varien_File_Uploader('bannerimage');
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
// or pdf or anything
$uploader->setAllowRenameFiles(false);
// setAllowRenameFiles(true) -> move your file in a folder the magento way
// setAllowRenameFiles(true) -> move your file directly in the $path folder
$uploader->setFilesDispersion(false);
$path = Mage::getBaseDir('media') . DS . 'footer_banner' . DS;
$uploader->save($path, $_FILES['bannerimage']['name']);
if ($data['position'] == 'left') {
$imgPath = $path . $_FILES['bannerimage']['name'];
$imageObj = new Varien_Image($imgPath);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(TRUE);
$imageObj->resize(466, 521);
$imageObj->save($imgPath);
} else {
$imgPath = $path . $_FILES['bannerimage']['name'];
$imageObj = new Varien_Image($imgPath);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(TRUE);
$imageObj->resize(269, 258);
$imageObj->save($imgPath);
}
$data['bannerimage'] = $_FILES['bannerimage']['name'];
$file_nm = str_replace(" ", "_", $_FILES['bannerimage']['name']);
$imgPath = Mage::getBaseUrl('media') . "footer_banner/" . $file_nm;
$data['filethumbgrid'] = '<img src="' . $imgPath . '" border="0" width="75" height="75" />';
} catch (Exception $e) {
}
}
$banner_id = $this->getRequest()->getParam('id');
if ($banner_id) {
$resource = Mage::getSingleton('core/resource');
$write = $resource->getConnection('core_write');
if ($file_nm) {
$file = "bannerimage = '" . $file_nm . "',";
} else {
$file = '';
}
if ($data['filethumbgrid']) {
$img_filed = "filethumbgrid='" . $data['filethumbgrid'] . "', ";
} else {
$img_filed = '';
}
$sql = "UPDATE banner SET block_id='" . $data['block_id'] . "'," . $file . $img_filed . "gender='" . $data['gender'] . "',link='" . $data['link'] . "',image_text='" . $data['image_text'] . "',position='" . $data['position'] . "' " . "WHERE banner_id = '" . $banner_id . "'";
$write->query($sql);
$message = 'Banner Settings updated !!';
} else {
Mage::getModel('banner/banner')->setBlockId($data['block_id'])->setBannerimage($file_nm)->setFilethumbgrid($data['filethumbgrid'])->setGender($data['gender'])->setImageText($data['image_text'])->setLink($data['link'])->setBanner_type('1')->setPosition($data['position'])->save();
$message = 'Banner Settings saved !!';
}
Mage::getSingleton('adminhtml/session')->addSuccess($message);
$this->_redirect('*/*/index');
}
开发者ID:rajarshc,项目名称:Rooja,代码行数:60,代码来源:BannerfooterController.php
示例2: getShortImageSize
public function getShortImageSize($item)
{
$width_max = Mage::getStoreConfig('clnews/news/shortdescr_image_max_width');
$height_max = Mage::getStoreConfig('clnews/news/shortdescr_image_max_height');
if (Mage::getStoreConfig('clnews/news/resize_to_max') == 1) {
$width = $width_max;
$height = $height_max;
} else {
$imageObj = new Varien_Image(Mage::getBaseDir('media') . DS . $item->getImageShortContent());
$original_width = $imageObj->getOriginalWidth();
$original_height = $imageObj->getOriginalHeight();
if ($original_width > $width_max) {
$width = $width_max;
} else {
$width = $original_width;
}
if ($original_height > $height_max) {
$height = $height_max;
} else {
$height = $original_height;
}
}
if ($item->getShortWidthResize()) {
$width = $item->getShortWidthResize();
} else {
$width;
}
if ($item->getShortHeightResize()) {
$height = $item->getShortHeightResize();
} else {
$height;
}
return array('width' => $width, 'height' => $height);
}
开发者ID:zloadmin,项目名称:modnyashka,代码行数:34,代码来源:News.php
示例3: postAction
public function postAction()
{
if (!empty($_FILES)) {
$type = 'file';
if (isset($_FILES[$type]['name']) && $_FILES[$type]['name'] != '') {
try {
$uploadsDir = Mage::getBaseDir('upload');
$uploader = new Varien_File_Uploader($type);
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(true);
$path = Mage::getBaseDir('media') . DS . 'upload';
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
$uploader->save($path, $_FILES[$type]['name']);
$filename = $uploader->getUploadedFileName();
$md5 = md5($filename);
$owner = Mage::getSingleton('customer/session')->getCustomerId() ? Mage::getSingleton('customer/session')->getCustomerId() : Mage::getSingleton('customer/session')->getSessionId();
Mage::getModel('xxx_catalog/upload')->setMd5($md5)->setFilename($filename)->setOwner($owner)->save();
$varienImage = new Varien_Image($uploadsDir . $filename);
$width = $varienImage->getOriginalWidth();
$height = $varienImage->getOriginalHeight();
$data = ['id' => $md5, 'width' => $width, 'height' => $height];
echo json_encode($data);
die;
} catch (Exception $e) {
Mage::log($e->getMessage(), null, $this->_logFile);
echo json_encode(['error' => $this->__($e->getMessage())]);
}
}
}
$this->getResponse()->setRedirect(Mage::getUrl('*/*/index'));
}
开发者ID:mkutyba,项目名称:sample-magento-code,代码行数:34,代码来源:UploadController.php
示例4: getCategoryImage
public function getCategoryImage($category = null, $width = 300, $height = 300, $image_type = "thumbnail")
{
if (empty($category) && !is_object($category)) {
return "";
}
if ($image_type == "thumbnail") {
$_file_name = $category->getThumbnail();
} else {
$_file_name = $category->getImage();
}
$_media_dir = Mage::getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS;
$cache_dir = $_media_dir . 'cache' . DS;
if ($_file_name) {
if (file_exists($cache_dir . $_file_name)) {
return Mage::getBaseUrl('media') . '/catalog/category/cache/' . $_file_name;
} elseif (file_exists($_media_dir . $_file_name)) {
if (!is_dir($cache_dir)) {
mkdir($cache_dir);
}
$_image = new Varien_Image($_media_dir . $_file_name);
$_image->constrainOnly(true);
$_image->keepAspectRatio(true);
$_image->keepTransparency(true);
$_image->resize((int) $width, (int) $height);
$_image->save($cache_dir . $_file_name);
return Mage::getBaseUrl('media') . '/catalog/category/cache/' . $_file_name;
}
}
return "";
}
开发者ID:booklein,项目名称:bookle,代码行数:30,代码来源:Categoriesinfo.php
示例5: _resizeSwatchImage
/**
* Performs the resize operation on the given swatch image file and returns a
* relative path to the resulting image file
*
* @param string $filename
* @param string $tag
* @param int $width
* @param int $height
* @return string
*/
protected function _resizeSwatchImage($filename, $tag, $width, $height)
{
if (!Mage::helper('uaudio_storage')->isEnabled()) {
return parent::_resizeSwatchImage($filename, $tag, $width, $height);
}
// Form full path to where we want to cache resized version
$destPathArr = array(self::SWATCH_CACHE_DIR, Mage::app()->getStore()->getId(), $width . 'x' . $height, $tag, trim($filename, '/'));
$destPath = implode('/', $destPathArr);
$storageModel = Mage::getSingleton('core/file_storage')->getStorageModel();
// Check if cached image exists already
$fullDest = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . $destPath;
if (!$storageModel->fileExists($fullDest)) {
// Check for source image
if ($tag == 'product') {
$sourceFilePath = Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath() . $filename;
} else {
$sourceFilePath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . self::SWATCH_FALLBACK_MEDIA_DIR . DS . $filename;
}
if (!$storageModel->fileExists($sourceFilePath)) {
return false;
}
// Do resize and save
$tmpFile = $storageModel->copyFiletoTmp($sourceFilePath);
$processor = new Varien_Image($tmpFile);
$processor->resize($width, $height);
$processor->save($tmpFile);
$storageModel->moveFile($tmpFile, $fullDest);
}
return $destPath;
}
开发者ID:uaudio,项目名称:magento-filestorage,代码行数:40,代码来源:Productimg.php
示例6: saveAction
public function saveAction()
{
$data = $this->getRequest()->getPost();
if (isset($_FILES['bannerimage']['name']) and file_exists($_FILES['bannerimage']['tmp_name'])) {
try {
$uploader = new Varien_File_Uploader('bannerimage');
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
// or pdf or anything
$uploader->setAllowRenameFiles(false);
// setAllowRenameFiles(true) -> move your file in a folder the magento way
// setAllowRenameFiles(true) -> move your file directly in the $path folder
$uploader->setFilesDispersion(false);
$path = Mage::getBaseDir('media') . DS . 'footer_banner' . DS;
$uploader->save($path, $_FILES['bannerimage']['name']);
$data['bannerimage'] = $_FILES['bannerimage']['name'];
//Create Thumbnail and upload
$imgName = $_FILES['bannerimage']['name'];
$imgPathFull = $path . $imgName;
$resizeFolder = "thumb";
$imageResizedPath = $path . $resizeFolder . DS . $imgName;
$imageObj = new Varien_Image($imgPathFull);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(TRUE);
$imageObj->resize(150, 150);
$imageObj->save($imageResizedPath);
//Create View Size and upload
$imgName = $_FILES['bannerimage']['name'];
$imgPathFull = $path . $imgName;
$resizeFolder = "medium";
$imageResizedPath = $path . $resizeFolder . DS . $imgName;
$imageObj = new Varien_Image($imgPathFull);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(TRUE);
$imageObj->resize(400, 400);
$imageObj->save($imageResizedPath);
} catch (Exception $e) {
}
}
$file_nm = str_replace(" ", "_", $_FILES['bannerimage']['name']);
$banner_id = $this->getRequest()->getParam('id');
$imgPath = Mage::getBaseUrl('media') . "footer_banner/thumb/" . $file_nm;
$data['filethumbgrid'] = '<img src="' . $imgPath . '" border="0" width="75" height="75" />';
// $bannerModel = Mage::getModel('banner/banner')->load();
//$bannerModel=Mage::getModel('banner/banner')->getCollection()->addFieldToFilter("banner_type",1)->getFirstItem();
if ($banner_id) {
$resource = Mage::getSingleton('core/resource');
$write = $resource->getConnection('core_write');
$sql = "UPDATE banner SET bannerimage = '" . $file_nm . "',filethumbgrid='" . $data['filethumbgrid'] . "' ,link='" . $data['link'] . "',position='" . $data['position'] . "' " . "WHERE banner_id = '" . $banner_id . "'";
$write->query($sql);
$message = 'Banner Settings updated !!';
} else {
Mage::getModel('banner/banner')->setBannerimage($file_nm)->setFilethumbgrid($data['filethumbgrid'])->setLink($data['link'])->setBanner_type('1')->setPosition($data['position'])->save();
$message = 'Banner Settings saved !!';
}
Mage::getSingleton('adminhtml/session')->addSuccess($message);
$this->_redirect('*/*/index');
}
开发者ID:rajarshc,项目名称:Rooja,代码行数:57,代码来源:BannersingleController.php
示例7: getCatResizedImage
public function getCatResizedImage($cat, $width, $height = null, $quality = 100)
{
if (!$cat->getThumbnail()) {
return false;
}
$imageUrl = Mage::getBaseDir('media') . DS . "catalog" . DS . "category" . DS . $cat->getThumbnail();
if (!is_file($imageUrl)) {
return false;
}
$imageResized = Mage::getBaseDir('media') . DS . "catalog" . DS . "category" . DS . "cache" . DS . "cat_resized" . DS . $cat->getThumbnail();
// Because clean Image cache function works in this folder only
//if (! file_exists ( $imageResized ) && file_exists ( $imageUrl ) || file_exists($imageUrl) && filemtime($imageUrl) > filemtime($imageResized)) :
$imageObj = new Varien_Image($imageUrl);
$imageObj->constrainOnly(true);
$imageObj->keepAspectRatio(true);
$imageObj->keepFrame(true);
// ep
$imageObj->quality($quality);
$imageObj->keepTransparency(true);
// png
$imageObj->backgroundColor(array(255, 255, 255));
$imageObj->resize($width, $height);
$imageObj->save($imageResized);
//endif;
if (file_exists($imageResized)) {
return Mage::getBaseUrl('media') . "/catalog/category/cache/cat_resized/" . $cat->getThumbnail();
} else {
return $this->getImageUrl();
}
}
开发者ID:quyip8818,项目名称:Mag,代码行数:30,代码来源:Catlist.php
示例8: getProfileImage
public function getProfileImage()
{
if (isset($this->_seller['sstech_profileimage']) && ($_file_name = $this->_seller['sstech_profileimage'])) {
$_media_dir = Mage::getBaseDir('media') . DS . 'customer' . DS;
// Here i create a resize folder. for upload new category image
$cache_dir = $_media_dir . 'resize' . DS;
if (file_exists($cache_dir . $_file_name)) {
$img = Mage::getBaseUrl('media') . 'customer' . DS . 'resize' . $_file_name;
} elseif (file_exists($_media_dir . $_file_name)) {
if (!is_dir($cache_dir)) {
mkdir($cache_dir);
}
$_image = new Varien_Image($_media_dir . $_file_name);
$_image->constrainOnly(false);
$_image->keepAspectRatio(true);
$_image->keepFrame(true);
$_image->keepTransparency(true);
$_image->backgroundColor(array(255, 255, 255));
$_image->resize(300, null);
// change image height, width
$_image->save($cache_dir . $_file_name);
$img = Mage::getBaseUrl('media') . 'customer' . DS . 'resize' . $_file_name;
}
}
if (!isset($img)) {
$img = Mage::getBaseUrl('media') . "default_user.jpg";
}
return $img;
}
开发者ID:enjoy2000,项目名称:gemz,代码行数:29,代码来源:Info.php
示例9: resizeImg
public function resizeImg($fileName, $width = '', $height = null)
{
$imageURL = $this->getBaseTmpMediaUrl() . $fileName;
$imagePath = $this->getBaseTmpMediaPath() . str_replace('/', DS, $fileName);
$extra = $width . 'x' . $height;
$newPath = $this->getBaseTmpMediaPath() . "cache" . DS . $extra . str_replace('/', DS, $fileName);
//if width empty then return original size image's URL
if ($width != '' && $height != '') {
//if image has already resized then just return URL
if (file_exists($imagePath) && is_file($imagePath) && !file_exists($newPath)) {
$imageObj = new Varien_Image($imagePath);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(FALSE);
$imageObj->keepTransparency(true);
$imageObj->keepFrame(FALSE);
$imageObj->quality(100);
//$width, $height - sizes you need (Note: when keepAspectRatio(TRUE), height would be ignored)
$imageObj->resize($width, $height);
$imageObj->save($newPath);
}
$resizedURL = $this->getBaseTmpMediaUrl() . "cache" . '/' . $extra . '/' . $fileName;
} else {
$resizedURL = $imageURL;
}
return $resizedURL;
}
开发者ID:uibar,项目名称:laviniailies2,代码行数:26,代码来源:Image.php
示例10: _entityImageUrl
protected function _entityImageUrl(Varien_Object $entity, $width, $height, $entityField)
{
$entityPath = $entity->getData($entityField);
if (!$entityPath) {
return null;
}
$dstPath = array('cache', Mage::app()->getStore()->getId(), $entityField, $width . 'x' . $height, $entityPath);
$dstFile = $this->getBaseMediaPath() . DS . implode(DS, $dstPath);
if (!file_exists($dstFile)) {
$srcPath = array($entityPath);
$srcFile = $this->getBaseMediaPath() . DS . implode(DS, $srcPath);
if (!file_exists($srcFile)) {
return null;
}
$image = new Varien_Image($srcFile);
$image->keepAspectRatio(true);
$image->keepTransparency(true);
$image->keepFrame(true);
$image->constrainOnly(false);
$image->backgroundColor(array(255, 255, 255));
$image->resize($width, $height);
$image->save($dstFile);
}
return $this->getBaseMediaUrl() . '/' . implode('/', $dstPath);
}
开发者ID:creatuitydevelopers,项目名称:mega-menu,代码行数:25,代码来源:Image.php
示例11: resizeImg
public function resizeImg($fileName, $width, $height = null)
{
$baseURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
$imageURL = $baseURL . '/' . 'magiccart/blog' . '/' . $fileName;
$basePath = Mage::getBaseDir('media');
$imagePath = $basePath . DS . 'magiccart/blog/' . str_replace('/', DS, $fileName);
$extra = $width . 'x' . $height;
$newPath = Mage::getBaseDir('media') . DS . 'magiccart/blog' . DS . "cache" . DS . $extra . '/' . str_replace('/', DS, $fileName);
//if width empty then return original size image's URL
if ($width != '' && $height != '') {
//if image has already cache then just return URL
if (file_exists($imagePath) && is_file($imagePath) && !file_exists($newPath)) {
$imageObj = new Varien_Image($imagePath);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(FALSE);
$imageObj->keepTransparency(true);
$imageObj->keepFrame(FALSE);
$imageObj->quality(100);
//$width, $height - sizes you need (Note: when keepAspectRatio(TRUE), height would be ignored)
$imageObj->resize($width, $height);
$imageObj->save($newPath);
}
$cacheURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . "magiccart/blog" . '/' . "cache" . '/' . $extra . '/' . $fileName;
} else {
$cacheURL = $imageURL;
}
return $cacheURL;
}
开发者ID:uibar,项目名称:laviniailies2,代码行数:28,代码来源:Images.php
示例12: resize
public function resize($imageUrl, $width, $height)
{
if (!file_exists(Mage::getBaseDir('media') . DS . "catalog" . DS . "category" . DS . "resized")) {
mkdir(Mage::getBaseDir('media') . DS . "catalog" . DS . "category" . DS . "resized", 0777, true);
}
$imageName = substr(strrchr($imageUrl, "/"), 1);
if ('255,255,255' !== $this->getBackgroundColor(true)) {
$imageName = $width . 'x' . $height . '/' . $this->getBackgroundColor(true) . '/' . $imageName;
} else {
$imageName = $width . 'x' . $height . '/' . $imageName;
}
$imageResized = Mage::getBaseDir('media') . DS . "catalog" . DS . "category" . DS . "resized" . DS . $imageName;
$imagePath = str_replace(Mage::getBaseUrl('media'), 'media/', $imageUrl);
$imagePath = Mage::getBaseDir() . DS . str_replace("/", DS, $imagePath);
if (!file_exists($imageResized) && file_exists($imagePath)) {
$imageObj = new Varien_Image($imagePath);
$imageObj->constrainOnly(true);
$imageObj->keepAspectRatio(true);
$imageObj->keepFrame(true);
$imageObj->keepTransparency(true);
$imageObj->backgroundColor($this->getBackgroundColor());
$imageObj->resize($width, $height);
$imageObj->save($imageResized);
}
$imageUrl = Mage::getBaseUrl('media') . "catalog/category/resized/" . $imageName;
return $imageUrl;
}
开发者ID:rommmka,项目名称:easycatalogimg,代码行数:27,代码来源:Image.php
示例13: getResizeImage
public function getResizeImage($name, $width = 255, $height = 255)
{
if (!$name) {
return;
}
$imagePathFull = Mage::getBaseDir('media') . DS . 'em_slideshow' . DS . $name;
$resizePath = $width . 'x' . $height;
$resizePathFull = Mage::getBaseDir('media') . DS . 'em_slideshow' . DS . 'resize' . DS . $resizePath . DS . $name;
if (file_exists($imagePathFull) && !file_exists($resizePathFull)) {
$imageObj = new Varien_Image($imagePathFull);
$imageObj->constrainOnly(TRUE);
$imageObj->resize($width, $height);
$imageObj->save($resizePathFull);
}
return Mage::getBaseUrl('media') . 'em_slideshow/resize/' . $resizePath . "/" . $name;
}
开发者ID:technomagegithub,项目名称:magento,代码行数:16,代码来源:Images.php
示例14: getThumbnailImage
public function getThumbnailImage($image, $width = 255, $height = 255)
{
if (!$image) {
return;
}
$imagePathFull = Mage::getBaseDir('media') . DS . 'cdz' . DS . 'revslideshow' . DS . 'images' . DS . $image;
$resizePath = $width . 'x' . $height;
$resizePathFull = Mage::getBaseDir('media') . DS . 'cdz' . DS . 'revslideshow' . DS . 'resize' . DS . $resizePath . DS . $image;
if (file_exists($imagePathFull) && !file_exists($resizePathFull)) {
$imageObj = new Varien_Image($imagePathFull);
$imageObj->constrainOnly(TRUE);
$imageObj->resize($width, $height);
$imageObj->save($resizePathFull);
}
return str_replace('index.php/', '', Mage::getBaseUrl('media')) . 'cdz/revslideshow/resize/' . $resizePath . "/" . $image;
}
开发者ID:CodazonGroup,项目名称:coda,代码行数:16,代码来源:Data.php
示例15: getPopupActive
public function getPopupActive()
{
$preview = $this->getRequest()->getParam('popup');
$popupID = $this->getRequest()->getParam('popupid');
if ($preview == "preview" && !empty($popupID)) {
$arrPopup = Mage::getModel('popup/popup')->getPopupPreview($popupID);
} else {
$arrPopup = Mage::getModel('popup/popup')->getPopupActive();
}
if (!empty($arrPopup)) {
// If there is a link, process template tag
if (!empty($arrPopup["popup_url"])) {
$helper = Mage::helper('cms');
$processor = $helper->getPageTemplateProcessor();
$arrPopup["popup_url"] = $processor->filter($arrPopup["popup_url"]);
}
// If there is a content, process template tag
if (!empty($arrPopup["popup_content_html"])) {
$helper = Mage::helper('cms');
$processor = $helper->getPageTemplateProcessor();
$arrPopup["popup_content_html"] = $processor->filter($arrPopup["popup_content_html"]);
}
$popupID = $arrPopup["popup_id"];
$storeID = Mage::app()->getStore()->getId();
//Check Cookie
$cookiePopup = Mage::getSingleton('core/cookie')->get('cookie_popup_' . $storeID);
// If there's any cookie or new promo or preview mode
if (!$cookiePopup || $cookiePopup != $popupID || $this->getRequest()->getParam('popup') == 'preview') {
if (!$this->getRequest()->getParam('popup')) {
Mage::getSingleton('core/cookie')->set('cookie_popup_' . $storeID, $popupID, 3600 * 24 * 7);
}
if (!empty($arrPopup["popup_image"])) {
$pathImage = Mage::getBaseDir('media') . "/popup/" . $arrPopup["popup_image"];
if (file_exists($pathImage)) {
$imageObj = new Varien_Image($pathImage);
$arrPopup['popup_image_width'] = $imageObj->getOriginalWidth();
$arrPopup['popup_image_height'] = $imageObj->getOriginalHeight();
}
}
return $arrPopup;
}
} else {
return false;
}
}
开发者ID:purpleweb,项目名称:magento-popup,代码行数:45,代码来源:Popup.php
示例16: getLableImage
public function getLableImage($fileName)
{
//$fileName = Mage::getStoreConfig('productlable/sample/newimage');
$width = 50;
$height = 50;
$folderURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
$imageURL = $folderURL . $fileName;
$basePath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . 'theme' . DS . $fileName;
$newPath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . "resized" . 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 = new Varien_Image($basePath);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(FALSE);
$imageObj->keepFrame(FALSE);
$imageObj->keepTransparency(TRUE);
$imageObj->resize($width, $height);
$imageObj->save($newPath);
}
$resizedURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . "resized/" . $fileName;
} else {
$resizedURL = $imageURL;
}
return $resizedURL;
}
开发者ID:danielwalterrodrigues,项目名称:asus,代码行数:27,代码来源:Productlable.php
示例17: resizeImg
/**
* Resize image
*
* @param string $fileName
* @param int $width
* @param int $height
* @return string Resized image url
*/
public function resizeImg($fileName, $width, $height = '')
{
if (!$height) {
$height = $width;
}
$thumbDir = self::IMAGE_THUMB_DIR;
$resizeDir = $thumbDir . "/resized_{$width}x{$height}";
$ioFile = new Varien_Io_File();
$ioFile->checkandcreatefolder(Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . $resizeDir);
$imageParts = explode('/', $fileName);
$imageFile = end($imageParts);
$folderURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
$imageURL = $folderURL . $fileName;
$basePath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . $fileName;
$newPath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . $resizeDir . DS . $imageFile;
if ($width != '') {
if (file_exists($basePath) && is_file($basePath) && !file_exists($newPath)) {
$imageObj = new Varien_Image($basePath);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(TRUE);
$imageObj->keepFrame(FALSE);
$imageObj->keepTransparency(TRUE);
//$imageObj->backgroundColor(array(255,255,255));
$imageObj->resize($width, $height);
$imageObj->save($newPath);
}
$resizedURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $resizeDir . '/' . $imageFile;
} else {
$resizedURL = $imageURL;
}
return $resizedURL;
}
开发者ID:perseusl,项目名称:kingdavid,代码行数:40,代码来源:Images.php
示例18: resizeImg
public function resizeImg($fileName, $width, $height = '')
{
$folderURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
$imageURL = $folderURL . $fileName;
$basePath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . $fileName;
$newPath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . "resized" . 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 = new Varien_Image($basePath);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(TRUE);
$imageObj->keepFrame(TRUE);
$imageObj->backgroundColor(array(255, 255, 255));
// white background!
$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:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:25,代码来源:Data.php
示例19: resizeCategoryImage
public function resizeCategoryImage($file_name, $resize = 550)
{
$file_name;
$resize_dir = 'resized-' . $resize;
$category_dir = 'catalog' . DS . 'category';
$category_path = $_SERVER['DOCUMENT_ROOT'] . DS . 'media' . DS . $category_dir;
$full_resized_url_path = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $category_dir . DS . $resize_dir . DS;
if (file_exists($category_path . DS . $resize_dir . DS . $file_name)) {
return $full_resized_url_path . $file_name;
}
if (file_exists($category_path . DS . $file_name)) {
if (!is_dir($category_path . DS . $resize_dir)) {
mkdir($category_path . DS . $resize_dir);
}
$_image = new Varien_Image($category_path . DS . $file_name);
$_image->constrainOnly(true);
$_image->keepAspectRatio(false);
$_image->keepFrame(false);
$_image->keepTransparency(true);
$_image->resize($resize);
$_image->save($category_path . DS . $resize_dir . DS . $file_name);
$catImg = $full_resized_url_path . $file_name;
}
return $catImg;
}
开发者ID:adampmoss,项目名称:hutch,代码行数:25,代码来源:Data.php
示例20: resizeImage
public function resizeImage($image, $type = "l", $width, $height, $storeid = null)
{
$image = str_replace("/", DS, $image);
$_imageUrl = Mage::getBaseDir('media') . DS . $image;
if ($storeid === null) {
$storeid = Mage::app()->getStore()->getId();
}
if (!$storeid) {
$imageResized = Mage::getBaseDir('media') . DS . "resized" . DS . $type . DS . $image;
} else {
$image2 = str_replace("blog" . DS, "", $image);
$image = "blog" . DS . $storeid . DS . $image2;
$imageResized = Mage::getBaseDir('media') . DS . "resized" . DS . $type . DS . "blog" . DS . $storeid . DS . $image2;
}
if (!file_exists($imageResized) && file_exists($_imageUrl)) {
$imageObj = new Varien_Image($_imageUrl);
$imageObj->quality(100);
$imageObj->constrainOnly(true);
$imageObj->keepAspectRatio(false);
$imageObj->keepFrame(false);
$imageObj->keepTransparency(true);
$imageObj->resize($width, $height);
$imageObj->save($imageResized);
}
return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'resized/' . "{$type}/" . str_replace(DS, "/", $image);
}
开发者ID:quanghuynt93,项目名称:VesSmartshop,代码行数:26,代码来源:Data.php
注:本文中的Varien_Image类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论