Example #1
0
 /**
  * Check - is this file an image
  *
  * @param string $filePath
  * @return bool
  * @throws Mage_Core_Exception
  */
 public function validateUploadFile($filePath)
 {
     if (!getimagesize($filePath)) {
         Mage::throwException($this->__('Disallowed file type.'));
     }
     $_processor = new Varien_Image($filePath);
     return $_processor->getMimeType() !== null;
 }
Example #2
0
 /**
  * Check - is this file an image
  *
  * @param string $filePath
  * @return bool
  * @throws Mage_Core_Exception
  */
 public function validateUploadFile($filePath)
 {
     if (!getimagesize($filePath)) {
         Mage::throwException($this->__('Disallowed file type.'));
     }
     $adapter = Mage::helper('Mage_Core_Helper_Data')->getImageAdapterType();
     $_processor = new Varien_Image($filePath, $adapter);
     return $_processor->getMimeType() !== null;
 }
Example #3
0
 /**
  * Create preview image
  *
  * @param string $imagePath
  * @return string
  */
 public function createPreviewImage($imagePath)
 {
     $adapter = Mage::helper('Mage_Core_Helper_Data')->getImageAdapterType();
     $image = new Varien_Image($imagePath, $adapter);
     $image->keepTransparency(true);
     $image->constrainOnly(true);
     $image->keepFrame(true);
     $image->keepAspectRatio(true);
     $image->backgroundColor(array(255, 255, 255));
     $image->resize(self::PREVIEW_IMAGE_WIDTH, self::PREVIEW_IMAGE_HEIGHT);
     $imageName = uniqid('preview_image_') . image_type_to_extension($image->getMimeType());
     $image->save($this->_getImagePathPreview(), $imageName);
     $this->setPreviewImage($imageName);
     return $imageName;
 }
 /**
  * Check - is this file an image
  *
  * @param string $filePath
  * @return bool
  * @throws Mage_Core_Exception
  */
 public function validateUploadFile($filePath)
 {
     $maxDimension = Mage::getStoreConfig(self::XML_NODE_PRODUCT_MAX_DIMENSION);
     $imageInfo = getimagesize($filePath);
     if (!$imageInfo) {
         Mage::throwException($this->__('Disallowed file type.'));
     }
     if ($imageInfo[0] > $maxDimension || $imageInfo[1] > $maxDimension) {
         Mage::throwException($this->__('Disalollowed file format.'));
     }
     $_processor = new Varien_Image($filePath);
     return $_processor->getMimeType() !== null;
 }