/** * Creates the different versions of images that are configured * * @param Model $Model * @param array $record * @param array $operations * @throws Exception * @return void */ protected function _createVersions(Model $Model, $record, $operations) { $Storage = StorageManager::adapter($record['adapter']); $path = $this->_buildPath($record, true); $tmpFile = $this->_tmpFile($Storage, $path); foreach ($operations as $version => $imageOperations) { $hash = $Model->hashOperations($imageOperations); $string = $this->_buildPath($record, true, $hash); if ($this->adapterClass === 'AmazonS3' || $this->adapterClass === 'AwsS3') { $string = str_replace('\\', '/', $string); } if ($Storage->has($string)) { return false; } try { $image = $Model->processImage($tmpFile, null, array('format' => $record['extension']), $imageOperations); $result = $Storage->write($string, $image->get($record['extension'], $this->options['imageOptions']), true); } catch (Exception $e) { $this->log($e->getMessage(), 'file_storage'); unlink($tmpFile); throw $e; } } unlink($tmpFile); }
/** * Creates the different versions of images that are configured * * @param Model $Model * @param array $record * @param array $operations * @return void */ protected function _createVersions($Model, $record, $operations) { $Storage = StorageManager::adapter($record['adapter']); $path = $this->_buildPath($record, true); $tmpFile = $this->_tmpFile($Storage, $path); foreach ($operations as $version => $imageOperations) { $hash = $Model->hashOperations($imageOperations); $string = $this->_buildPath($record, true, $hash); if ($Storage->has($string)) { continue; } try { $image = $Model->processImage($tmpFile, null, array('format' => $record['extension']), $imageOperations); $result = $Storage->write($string, $image->get($record['extension']), true); } catch (Exception $e) { $this->log($e->getMessage(), 'file_storage'); unlink($tmpFile); throw $e; } } unlink($tmpFile); }