Esempio n. 1
0
 /**
  * Resize an image according to given parameter.
  *
  * @throws \Exception
  * @param string $fileNameAndPath
  * @param int $width
  * @param int $height
  * @return void
  */
 public function resize($fileNameAndPath, $width = 0, $height = 0)
 {
     // Skip profile of the image
     $imParams = '###SkipStripProfile###';
     $options = array('maxW' => $width, 'maxH' => $height);
     $tempFileInfo = $this->gifCreator->imageMagickConvert($fileNameAndPath, '', '', '', $imParams, '', $options, TRUE);
     if ($tempFileInfo) {
         // Overwrite original file
         @unlink($fileNameAndPath);
         @rename($tempFileInfo[3], $fileNameAndPath);
     }
 }
Esempio n. 2
0
 /**
  * Optimize the given uploaded image
  *
  * @param \Fab\Media\FileUpload\UploadedFileInterface $uploadedFile
  * @return \Fab\Media\FileUpload\UploadedFileInterface
  */
 public function optimize($uploadedFile)
 {
     $orientation = $this->getOrientation($uploadedFile->getFileWithAbsolutePath());
     $isRotated = $this->isRotated($orientation);
     // Only rotate image if necessary!
     if ($isRotated > 0) {
         $transformation = $this->getTransformation($orientation);
         $imParams = '###SkipStripProfile###';
         if ($transformation !== '') {
             $imParams .= ' ' . $transformation;
         }
         $tempFileInfo = $this->gifCreator->imageMagickConvert($uploadedFile->getFileWithAbsolutePath(), '', '', '', $imParams, '', array(), TRUE);
         if ($tempFileInfo) {
             // Replace original file
             @unlink($uploadedFile->getFileWithAbsolutePath());
             @rename($tempFileInfo[3], $uploadedFile->getFileWithAbsolutePath());
             if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] === 'gm') {
                 $this->resetOrientation($uploadedFile->getFileWithAbsolutePath());
             }
         }
     }
     return $uploadedFile;
 }
 /**
  * Calculate new dimensions for SVG image
  * No cropping, if cropped info present image is scaled down
  *
  * @param Resource\FileInterface $file
  * @param array $configuration
  * @param array $options
  * @param GifBuilder $gifBuilder
  * @return array width,height
  */
 protected function getNewSvgDimensions($file, array $configuration, array $options, GifBuilder $gifBuilder)
 {
     $info = array($file->getProperty('width'), $file->getProperty('height'));
     $data = $gifBuilder->getImageScale($info, $configuration['width'], $configuration['height'], $options);
     // Turn cropScaling into scaling
     if ($data['crs']) {
         if (!$data['origW']) {
             $data['origW'] = $data[0];
         }
         if (!$data['origH']) {
             $data['origH'] = $data[1];
         }
         if ($data[0] > $data['origW']) {
             $data[1] = (int) ($data['origW'] * $data[1] / $data[0]);
             $data[0] = $data['origW'];
         } else {
             $data[0] = (int) ($data['origH'] * $data[0] / $data[1]);
             $data[1] = $data['origH'];
         }
     }
     return array('width' => $data[0], 'height' => $data[1]);
 }
Esempio n. 4
0
 /**
  * Writes the input GDlib image pointer to file
  *
  * @param	resource	The GDlib image resource pointer
  * @param	string		The filename to write to
  * @return	mixed		The output of either imageGif, imagePng or imageJpeg based on the filename to write
  * @see maskImageOntoImage(), scale(), output()
  */
 public function ImageWrite($destImg, $theImage)
 {
     return parent::ImageWrite($destImg, PATH_site . $theImage);
 }