Example #1
0
 public function generate()
 {
     $this->calculate();
     $crop = new Image_Image();
     $crop->createImageTrueColorTransparent($this->canvas_x, $this->canvas_y);
     $src_x = $this->_owner->getHandleX() - floor($this->canvas_x / 2);
     $src_y = $this->_owner->getHandleY() - floor($this->canvas_y / 2);
     imagecopy($crop->image, $this->_owner->image, 0, 0, $src_x, $src_y, $this->canvas_x, $this->canvas_y);
     $this->_owner->image = $crop->image;
     unset($crop);
     return true;
 }
Example #2
0
 public function generate()
 {
     $src_x = $this->_owner->imagesx();
     $src_y = $this->_owner->imagesy();
     $temp = new Image_Image();
     $temp->createImageTrueColorTransparent($src_x, $src_y + 20);
     $text = str_replace("[Filename]", $this->_owner->getSettings('filename'), $this->info);
     switch ($this->position) {
         case "t":
             $x = 0;
             $y = 20;
             $bar_y = 0;
             $text_y = 3;
             break;
         case "b":
             $x = 0;
             $y = 0;
             $bar_y = $src_y + 20;
             $text_y = $bar_y - 20 + 3;
             break;
         default:
             return false;
             break;
     }
     switch ($this->justify) {
         case "l":
             $text_x = 3;
             break;
         case "c":
             $text_x = ($src_x - imagefontwidth($this->font) * strlen($text)) / 2;
             break;
         case "r":
             $text_x = $src_x - 3 - imagefontwidth($this->font) * strlen($text);
             break;
     }
     //Draw the bar background
     $arrColor = $this->_owner->hexColorToArrayColor($this->barcolor);
     $bar_color = imagecolorallocate($temp->image, $arrColor['red'], $arrColor['green'], $arrColor['blue']);
     imagefilledrectangle($temp->image, 0, $bar_y, $src_x, 20, $bar_color);
     //Copy the image
     imagecopy($temp->image, $this->_owner->image, $x, $y, 0, 0, $src_x, $src_y);
     //Draw the text (to be replaced with image_draw_text one day
     $arrColor = $this->_owner->hexColorToArrayColor($this->textcolor);
     $text_color = imagecolorallocate($temp->image, $arrColor['red'], $arrColor['green'], $arrColor['blue']);
     imagestring($temp->image, $this->font, $text_x, $text_y, $text, $text_color);
     $this->_owner->image = $temp->image;
     unset($temp);
     return true;
 }
Example #3
0
 public function generate()
 {
     $width = $this->_owner->imagesx();
     $height = $this->_owner->imagesy();
     $temp = new Image_Image();
     if (!empty($this->color)) {
         $temp->createImageTrueColor($width + ($this->r + $this->l), $height + ($this->t + $this->b));
         $arrColor = Image_Image::hexColorToArrayColor($this->color);
         $tempcolor = imagecolorallocate($temp->image, $arrColor['red'], $arrColor['green'], $arrColor['blue']);
         imagefilledrectangle($temp->image, 0, 0, $temp->imagesx(), $temp->imagesy(), $tempcolor);
     } else {
         $temp->createImageTrueColorTransparent($width + ($this->r + $this->l), $height + ($this->t + $this->b));
     }
     imagecopy($temp->image, $this->_owner->image, $this->l, $this->t, 0, 0, $width, $height);
     $this->_owner->image = $temp->image;
     unset($temp);
     return true;
 }
Example #4
0
 public function generate()
 {
     $width = $this->_owner->imagesx();
     $height = $this->_owner->imagesy();
     $distance = $this->distance;
     $matrix = $this->matrix;
     $matrix_width = count($matrix);
     $matrix_sum = array_sum($matrix);
     $c = 0;
     $m_offset = floor($matrix_width / 2);
     $temp = new Image_Image();
     $temp->createImageTrueColorTransparent($width + $matrix_width * 2, $height + $matrix_width * 2);
     imagecopy($temp->image, $this->_owner->image, $matrix_width, $matrix_width, 0, 0, $width, $height);
     $w = $temp->imagesx();
     $h = $temp->imagesy();
     for ($y = 0; $y < $h; $y++) {
         for ($x = 0; $x < $w; $x++) {
             $t = $temp->imagecolorat($x, $y);
             $t1 = Image_Image::intColorToArrayColor($t);
             $p[$x][$y]['r'] = $t1['red'];
             $p[$x][$y]['g'] = $t1['green'];
             $p[$x][$y]['b'] = $t1['blue'];
             $p[$x][$y]['a'] = $t1['alpha'];
             $p1[$x][$y]['r'] = 255;
             $p1[$x][$y]['g'] = 255;
             $p1[$x][$y]['b'] = 255;
             $p1[$x][$y]['a'] = 127;
         }
     }
     $w = $this->_owner->imagesx();
     $h = $this->_owner->imagesy();
     $d_offset = $distance - $matrix_width;
     if ($this->color != "image") {
         $arrColor = $this->_owner->hexColorToArrayColor($this->color);
     }
     $temp->createImageTrueColorTransparent($width + $distance + $m_offset, $height + $distance + $m_offset);
     imagesavealpha($temp->image, true);
     imagealphablending($temp->image, true);
     for ($i = $m_offset; $i < $w + $m_offset + $matrix_width; $i++) {
         for ($j = $m_offset; $j < $h + $m_offset + $matrix_width; $j++) {
             $sumr = 0;
             $sumg = 0;
             $sumb = 0;
             $suma = 0;
             for ($k = 0; $k < $matrix_width; $k++) {
                 $xx = $i - ($matrix_width >> 1) + $k;
                 $sumr += $p[$xx][$j]['r'] * $matrix[$k];
                 $sumg += $p[$xx][$j]['g'] * $matrix[$k];
                 $sumb += $p[$xx][$j]['b'] * $matrix[$k];
                 $suma += $p[$xx][$j]['a'] * $matrix[$k];
             }
             $p1[$i][$j]['r'] = $sumr / $matrix_sum;
             $p1[$i][$j]['g'] = $sumg / $matrix_sum;
             $p1[$i][$j]['b'] = $sumb / $matrix_sum;
             $p1[$i][$j]['a'] = $suma / $matrix_sum;
         }
     }
     for ($i = $m_offset; $i < $w + $m_offset + $matrix_width; $i++) {
         for ($j = $m_offset; $j < $h + $m_offset + $matrix_width; $j++) {
             $sumr = 0;
             $sumg = 0;
             $sumb = 0;
             $suma = 0;
             for ($k = 0; $k < $matrix_width; $k++) {
                 $xy = $j - ($matrix_width >> 1) + $k;
                 $sumr += $p1[$i][$xy]['r'] * $matrix[$k];
                 $sumg += $p1[$i][$xy]['g'] * $matrix[$k];
                 $sumb += $p1[$i][$xy]['b'] * $matrix[$k];
                 $suma += $p1[$i][$xy]['a'] * $matrix[$k];
             }
             if ($this->color != "image") {
                 $col = imagecolorallocatealpha($temp->image, $arrColor['red'], $arrColor['green'], $arrColor['blue'], $suma / $matrix_sum);
             } else {
                 $col = imagecolorallocatealpha($temp->image, $sumr / $matrix_sum, $sumg / $matrix_sum, $sumb / $matrix_sum, $suma / $matrix_sum);
             }
             imagesetpixel($temp->image, $i + $d_offset, $j + $d_offset, $col);
         }
     }
     imagecopy($temp->image, $this->_owner->image, 0, 0, 0, 0, $width, $height);
     $this->_owner->image = $temp->image;
     unset($temp);
     return true;
 }
Example #5
0
 public function generate()
 {
     imagesavealpha($this->_owner->image, true);
     imagealphablending($this->_owner->image, false);
     $image_x = $this->_owner->imagesx();
     $image_y = $this->_owner->imagesy();
     $gdCorner = imagecreatefromstring(base64_decode($this->_cornerpng()));
     $corner = new Image_Image();
     $corner->createImageTrueColorTransparent($this->radius_x, $this->radius_y);
     imagecopyresampled($corner->image, $gdCorner, 0, 0, 0, 0, $this->radius_x, $this->radius_y, imagesx($gdCorner), imagesy($gdCorner));
     $corner_x = $this->radius_x - 1;
     $corner_y = $this->radius_y - 1;
     for ($y = 0; $y < $corner_y; $y++) {
         for ($x = 0; $x < $corner_x; $x++) {
             for ($c = 0; $c < 4; $c++) {
                 switch ($c) {
                     case 0:
                         $xo = 0;
                         $yo = 0;
                         $cxo = $x;
                         $cyo = $y;
                         break;
                     case 1:
                         $xo = $image_x - $corner_x;
                         $yo = 0;
                         $cxo = $corner_x - $x;
                         $cyo = $y;
                         break;
                     case 2:
                         $xo = $image_x - $corner_x;
                         $yo = $image_y - $corner_y;
                         $cxo = $corner_x - $x;
                         $cyo = $corner_y - $y;
                         break;
                     case 3:
                         $xo = 0;
                         $yo = $image_y - $corner_y;
                         $cxo = $x;
                         $cyo = $corner_y - $y;
                         break;
                 }
                 $irgb = imagecolorat($this->_owner->image, $xo + $x, $yo + $y);
                 $r = $irgb >> 16 & 0xff;
                 $g = $irgb >> 8 & 0xff;
                 $b = $irgb & 0xff;
                 $crgb = imagecolorat($corner->image, $cxo, $cyo);
                 $a = $crgb >> 24 & 0xff;
                 $colour = imagecolorallocatealpha($this->_owner->image, $r, $g, $b, $a);
                 switch ($c) {
                     case 0:
                         imagesetpixel($this->_owner->image, $x, $y, $colour);
                         break;
                     case 1:
                         imagesetpixel($this->_owner->image, $xo + $x, $y, $colour);
                         break;
                     case 2:
                         imagesetpixel($this->_owner->image, $xo + $x, $yo + $y, $colour);
                         break;
                     case 3:
                         imagesetpixel($this->_owner->image, $x, $yo + $y, $colour);
                         break;
                 }
             }
         }
     }
 }
Example #6
0
<?php

require_once dirname(__FILE__) . '/bootstrap.php';
$image = new Image_Image();
$image->createImageTrueColorTransparent(192, 96);
$image->attach(new Image_Fx_Canvassize(0, 0, 0, 0, "FFFFFF"));
$image->attach(new Image_Draw_Border(1, "BBBBBB"));
$image->attach(new Image_Draw_Border(1, "FFFFFF"));
$image->imagePng();
Example #7
0
 public function generate()
 {
     $src_x = $this->_owner->imagesx();
     $src_y = $this->_owner->imagesy();
     $this->calculate();
     $dst_x = $this->canvas_x;
     $dst_y = $this->canvas_y;
     $dst = new Image_Image();
     $dst->createImageTrueColorTransparent($dst_x, $dst_y);
     imagecopyresampled($dst->image, $this->_owner->image, 0, 0, 0, 0, $dst_x, $dst_y, $src_x, $src_y);
     $this->_owner->image = $dst->image;
     unset($dst);
     return true;
 }