Пример #1
0
 /**
  * Get memory needed to perform image manipulations on the file
  *
  * @param string
  * @return int
  */
 protected function _getNeedMemoryForFile($file = null)
 {
     if (!Mage::helper('uaudio_storage')->isEnabled()) {
         return parent::_getNeedMemoryForFile($file);
     }
     $file = is_null($file) ? $this->getBaseFile() : $file;
     if (!$file) {
         return 0;
     }
     if (!$this->_fileExists($file)) {
         return 0;
     }
     if ($this->_getStorageModel()->isInMedia($file)) {
         $metadata = $this->_getStorageModel()->getMetadata($file);
         if (!isset($metadata['width'])) {
             $imageInfo = getimagesize($this->_getFileFromStorage($file));
             $this->_getStorageModel()->updateMetadata($file, ['width' => $imageInfo[0], 'height' => $imageInfo[1]]);
         } else {
             $imageInfo[0] = $metadata['width'];
             $imageInfo[1] = $metadata['height'];
         }
     } else {
         $imageInfo = getimagesize($file);
     }
     if (!isset($imageInfo[0]) || !isset($imageInfo[1])) {
         return 0;
     }
     if (!isset($imageInfo['channels'])) {
         // if there is no info about this parameter lets set it for maximum
         $imageInfo['channels'] = 4;
     }
     if (!isset($imageInfo['bits'])) {
         // if there is no info about this parameter lets set it for maximum
         $imageInfo['bits'] = 8;
     }
     return round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $imageInfo['channels'] / 8 + Pow(2, 16)) * 1.65);
 }