Beispiel #1
0
 public function save($quality = 100)
 {
     $contents = Library::getContentsFromGDResource($this->resource, $this->format, $quality);
     $format = $this->format;
     $extension = $this->getExtensionFromFormat($format);
     $mime = $this->getMimeFromFormat($format);
     return array('contents' => $contents, 'format' => $format, 'extension' => $extension, 'mime' => $mime);
 }
Beispiel #2
0
 protected function setFrames()
 {
     foreach ($this->background->frames as $framekey => $frame) {
         if ($framekey === 0 || $frame['disposalmethod'] === '010' || $this->background->frames[$framekey - 1]['disposalmethod'] === '010') {
             $resource = imagecreatetruecolor($this->background->width, $this->background->height);
             if (isset($this->fill) === true) {
                 $backgroundindex = imagecolorallocate($resource, $this->fill['red'], $this->fill['green'], $this->fill['blue']);
                 imagefill($resource, 0, 0, $backgroundindex);
             } else {
                 $backgroundindex = imagecolorallocatealpha($resource, 255, 255, 255, 127);
                 imagefill($resource, 0, 0, $backgroundindex);
                 imagecolortransparent($resource, $backgroundindex);
             }
             imagecopy($resource, $frame['resource'], 0, 0, 0, 0, $this->background->width, $this->background->height);
             if (isset($this->layersresource) === true) {
                 imagecopy($resource, $this->layersresource, 0, 0, 0, 0, $this->background->width, $this->background->height);
             }
         } else {
             $resource = imagecreatetruecolor($this->background->width, $this->background->height);
             $transparentindex = imagecolorallocatealpha($resource, 255, 255, 255, 127);
             imagefill($resource, 0, 0, $transparentindex);
             imagecolortransparent($resource, $transparentindex);
             imagecopy($resource, $frame['resource'], 0, 0, 0, 0, $this->background->width, $this->background->height);
             if (isset($this->layersresource) === true) {
                 if (isset($this->layerscoordinates) === false) {
                     $this->setLayersCoordinates();
                 }
                 imagealphablending($resource, false);
                 foreach ($this->layerscoordinates as $layerscoordinate) {
                     imagesetpixel($resource, $layerscoordinate['x'], $layerscoordinate['y'], $transparentindex);
                 }
             }
         }
         $this->frames[$framekey]['disposalmethod'] = $frame['disposalmethod'];
         $this->frames[$framekey]['delaytime'] = $frame['delaytime'];
         $contents = Library::getContentsFromGDResource($resource, 'gif');
         $this->frames[$framekey]['fileobject'] = Library::getFileObjectFromContents($contents);
     }
 }