示例#1
0
 private function thumbs()
 {
     $data = json_decode($_POST['data'], true);
     for ($index = 0, $total = count($this->thumbnails); $index < $total; ++$index) {
         list($width, $height, $scale, $rotate, $horizontal, $vertical, $color, $opacity, $quality) = array($this->thumbnails[$index]['width'], $this->thumbnails[$index]['height'], 1.0, 0.0, $this->thumbnails[$index]['width'] * 0.5, $this->thumbnails[$index]['height'] * 0.5, array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0), 1.0, $data['quality']);
         $transformation = new ZapTransformation($scale, $rotate, new ZapPosition($horizontal, $vertical), new ZapColor($color['r'], $color['g'], $color['b'], $color['a']), $opacity);
         $in = ZapStream::createFromFile(sprintf('%s/%s', _, $this->retouched));
         $ou = ZapStream::create($width, $height);
         $zp = new Zap();
         $zp->process($transformation, $in, $ou);
         $ou->save(sprintf($this->thumbnail, $this->thumbnails[$index]['width'], $this->thumbnails[$index]['height']), $quality);
         $ou->dispose();
         $in->dispose();
         $in = $ou = null;
     }
 }
示例#2
0
 public function process(ZapTransformation $transformation, ZapStream &$streamIn, ZapStream &$streamOut)
 {
     $scale = $transformation->scale();
     $rotate = 0 - $transformation->rotate();
     $position = $transformation->position();
     $color = $transformation->color();
     $alpha = 1.27 * (100 - $color->alpha() * 100.0);
     $opacity = $transformation->opacity();
     $roBack = imagecolorallocatealpha($streamOut->resource(), $color->red(), $color->green(), $color->blue(), 127.0);
     $ouBack = imagecolorallocatealpha($streamOut->resource(), $color->red(), $color->green(), $color->blue(), $alpha);
     $this->opacity($streamIn, $opacity);
     $stream = ZapStream::createFromResource(imagerotate($streamIn->resource(), $rotate, $roBack));
     $z = array(0 - $stream->width() * $scale * 0.5, 0 - $stream->height() * $scale * 0.5);
     $p = array($z[0] + $position->x(), $z[1] + $position->y());
     imagealphablending($streamOut->resource(), true);
     imagefill($streamOut->resource(), $x = 0, $y = 0, $ouBack);
     imagecopyresampled($streamOut->resource(), $stream->resource(), $p[0], $p[1], 0, 0, $stream->width() * $scale, $stream->height() * $scale, $stream->width(), $stream->height());
     $stream->dispose();
     $stream = null;
 }