Exemplo n.º 1
0
 public function testResizedWithoutMaxOnly()
 {
     unlink(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'stretched.jpg');
     $originalPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'original.jpg';
     $path = ImageProcessor::resize($originalPath, array('maxOnly' => false, 'w' => 1500, 'resultDir' => dirname(__FILE__) . DIRECTORY_SEPARATOR, 'outputFilename' => 'stretched.jpg'));
     $imagesize = getimagesize($path);
     $this->assertEquals(1500, $imagesize[0]);
     $this->assertEquals(FileHelper::replaceSeparators(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'stretched.jpg'), $path);
 }
 protected function processTempImage($tmp, $options, $oldFile = '')
 {
     $tmp = str_replace('/', DIRECTORY_SEPARATOR, $tmp);
     try {
         $options = array_merge(array('onlyCreateWhenNew' => false, 'overwrite' => false), $options);
         /** delete previous images */
         if (!empty($oldFile) && file_exists($oldFile)) {
             unlink($oldFile);
         }
         $path = ImageProcessor::resize($tmp, $options);
     } catch (\Exception $e) {
         $this->app->getLogger()->log("error with message " . $e->getMessage());
         throw new \Exception($e->getMessage());
     }
     $path = str_replace(array($this->app->getTheme()->getPublicBasePath(), DIRECTORY_SEPARATOR), array('', '/'), $path);
     return $path;
 }