Exemplo n.º 1
0
 public function testCompressJpeg()
 {
     for ($i = 1; $i < 10; $i++) {
         $source = fopen("{$this->_files}/image_jpg.jpg", 'r');
         $uncompressed = fopen('php://temp', 'w+');
         $compressed = fopen('php://temp', 'w+');
         $subject = new Imagick($source);
         $subject->compress(0);
         $subject->store($uncompressed);
         $subject->compress($i);
         $subject->store($compressed);
         $uncompressedMeta = fstat($uncompressed);
         $compressedMeta = fstat($compressed);
         if (!$uncompressedMeta['size']) {
             return $this->markTestSkipped('Imagick compression is not working correctly.');
         }
         $this->assertLessThan($uncompressedMeta['size'], $compressedMeta['size'], "Compr. `{$i}`.");
         fclose($source);
         fclose($uncompressed);
         fclose($compressed);
     }
 }
Exemplo n.º 2
0
 public function extent($width, $height, $rgb)
 {
     $color = "rgb({$rgb[0]},{$rgb[1]},{$rgb[2]})";
     $new = new ImagickCore();
     $new->newImage($width, $height, $color);
     $new->compositeImage($this->_object, ImagickCore::COMPOSITE_OVER, $width / 2 - $this->width() / 2, $height / 2 - $this->height() / 2);
     $new->setFormat($this->_object->getFormat());
     $this->_object = $new;
     return true;
 }
Exemplo n.º 3
0
 public function background($rgb)
 {
     $color = "rgb({$rgb[0]},{$rgb[1]},{$rgb[2]})";
     $colorized = new ImagickCore();
     $colorized->newImage($this->width(), $this->height(), $color);
     $colorized->compositeImage($this->_object, ImagickCore::COMPOSITE_OVER, 0, 0);
     $this->_object = $colorized;
     return true;
 }