Ejemplo n.º 1
0
 function paste(img $draw, $dest_x, $dest_y, $src_x = null, $src_y = null, $dest_w = null, $dest_h = null, $src_w = null, $src_h = null)
 {
     // default is to paste the image cleanly at dest_x, dest_y
     if ($src_x === null) {
         $src_x = $src_y = 0;
         $dest_w = $src_w = $draw->getWidth();
         $dest_h = $src_h = $draw->getHeight();
     }
     // paste the image
     imagecopyresampled($this->img, $draw->img, $dest_x, $dest_y, $src_x, $src_y, $dest_w, $dest_h, $src_w, $src_h);
 }
Ejemplo n.º 2
0
 static function transform_image($spath, $dpath, $data)
 {
     $datas = explode(':', $data);
     $srcWidth = $datas[0];
     $srcHeight = $datas[1];
     $srcX = $datas[2];
     $srcY = $datas[3];
     $dstWidth = $datas[4];
     $dstHeight = $datas[5];
     img::load($spath);
     $origWidth = img::getWidth();
     $origHeight = img::getHeight();
     $xRatio = $origWidth / $srcWidth;
     $yRatio = $origHeight / $srcHeight;
     $srcWidth = $dstWidth * $xRatio;
     $srcHeight = $dstHeight * $yRatio;
     $srcX = $srcX * $xRatio;
     $srcY = $srcY * $yRatio;
     img::transform($srcX, $srcY, $srcWidth, $srcHeight, $dstWidth, $dstHeight);
     img::save($dpath);
     img::unload();
 }