Example #1
0
 public function index()
 {
     if ($this->input->get('file')) {
         $image_settings = array('filename' => $this->input->get('file'), 'width' => $this->input->get('width') ? $this->input->get('width') : FALSE, 'height' => $this->input->get('height') ? $this->input->get('height') : FALSE, 'maintain_ratio' => $this->input->get('mr') ? $this->input->get('mr') : FALSE, 'format' => $this->input->get('format') ? $this->input->get('format') : FALSE, 'maintain_transparency' => $this->input->get('maintain_transparency') ? $this->input->get('maintain_transparency') : FALSE, 'background' => $this->input->get('bk') ? DynamicImage::hexrgb($this->input->get('bk'), FALSE) : array(255, 255, 255));
         $myimage = new DynamicImage($image_settings);
     } else {
         throw new Kohana_Exception('An image file in GIF, JPG or PNG format is required');
     }
 }
Example #2
0
        } else {
            header('Content-Type: image/png');
        }
        $myImage = imagecreatetruecolor(self::WIDTH, self::HEIGHT);
        if (false !== $myImage) {
            $color = imagecolorallocate($myImage, 255, 0, 0);
            for ($i = 0; $i < self::WIDTH; $i++) {
                $color = imagecolorallocate($myImage, $i, 255 - $i, 0);
                if (false !== $color) {
                    imageline($myImage, 0, self::HEIGHT - 1, $i, 0, $color);
                }
                $color = imagecolorallocate($myImage, $i, 0, 255 - $i);
                if (false !== $color) {
                    imageline($myImage, self::WIDTH - 1, 0, self::WIDTH - 1 - $i, self::HEIGHT - 1, $color);
                }
            }
            $color = imagecolorallocate($myImage, 0, 0, 255);
            imagestring($myImage, 4, 10, 30, 'Hello', $color);
            $color = imagecolorallocate($myImage, 255, 255, 255);
            imagestring($myImage, 4, 10, 50, 'C# to PHP is fantastic', $color);
            if ($jpg) {
                imagejpeg($myImage, null, $compression);
            } else {
                imagepng($myImage);
            }
            imagedestroy($myImage);
        }
    }
}
DynamicImage::PhpMain();