/** * get the image processor * * @access protected * @return Varien_Image_Adapter_Gd2 * @author Ultimate Module Creator */ protected function _getImageProcessor() { if (is_null($this->_imageProcessor)) { $this->_imageProcessor = Varien_Image_Adapter::factory('GD2'); $this->_imageProcessor->keepFrame($this->_keepFrame); $this->_imageProcessor->keepAspectRatio($this->_keepAspectRatio); $this->_imageProcessor->constrainOnly($this->_constrainOnly); } return $this->_imageProcessor; }
public static function imageResize($image, $width = 100, $height = 100) { $newName = $width . 'x' . $height . '_' . $image; $basePath = self::getRealImageFolderPath(); if (file_exists($basePath . $newName)) { return $newName; } if (class_exists('Varien_Image_Adapter_Gd2')) { try { $_image = new Varien_Image_Adapter_Gd2(); $_image->open($basePath . $image); $_image->keepAspectRatio(true); $_image->resize($width, $height); if (Mage::helper('awfeatured')->checkVersion('1.4')) { $_image->save($basePath, $newName); } else { $_image->save(null, $newName); } return $newName; } catch (Exception $ex) { Mage::logException($ex); return false; } } return false; }
} $dispersionPath = substr($image, $imgPrefixLen); foreach ($dimensions as $thumbPrefix => $dimension) { $thumb = $thumbPrefix . $dispersionPath; $thumbInfo = $s3->getObjectInfo($bucket, $thumb, $compareThumbsBySize); //Check if thumb exists in the bucket if ($thumbInfo && !$_reuploadThumbs) { echo 'Thumb ', $thumb, ' exists', "\n"; continue; } if (!file_exists($thumb) || $recalculateThumbs) { //Create directories for the thumb createDirectory(substr($thumb, 0, strlen($thumbPrefix) + 4)); $adapter = new Varien_Image_Adapter_Gd2(); //Default settings from Mage $adapter->keepAspectRatio(true); $adapter->keepFrame(false); $adapter->keepTransparency(true); $adapter->constrainOnly(true); $adapter->backgroundColor(array(255, 255, 255)); $adapter->quality(100); try { $adapter->open($image); $adapter->resize($dimension['width'], $dimension['height']); $adapter->save($thumb); } catch (Exception $e) { echo 'Can\'t resize ', $image, ' (', $e->getMessage(), ')', "\n"; continue; } } if (file_exists($thumb)) {