Пример #1
0
function text2image($height, $text)
{
header("Content-type: image/png");
$width = $height * strlen($text)/ 5 * 2;
$font = "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf";
$image = imageCreate($width, $height);
$backgroundColor = imageColorAllocate($image, 255, 255, 255);
$textColor = imageColorAllocate($image, 0, 0, 0);
imagefttext($image, $height/2, 0, 0, $height/10*9, $textColor, $font, $text); 
imageInterlace($image, 1);
imageColorTransparent($image, $backgroundColor);
imagePNG($image);
}
Пример #2
0
<?php

header("Content-type:  image/gif");
dl('php3_gd.dll');
//header("Content-type:  image/png");
$image = imageCreate(100, 100);
imageGIF($image);
//imagePNG($image);
// create an interlaced image for better loading in the browser
imageInterlace($image, 1);
// mark background color as being transparent
$colorBackgr = imageColorAllocate($image, 192, 192, 192);
imageColorTransparent($image, $colorBackgr);
Пример #3
0
 /**
  * Print image to screen and send headers.
  *
  * @param resource $imageres	image gd resource
  * @param string $ext			image extension
  */
 protected function outputImage($imageres, $ext)
 {
     header("Content-Type: image/" . $ext);
     if ($ext == 'jpeg') {
         imagejpeg($imageres, NULL, 100);
     } else {
         if ($ext == 'gif') {
             imagegif($imageres);
         } else {
             if ($ext == 'png') {
                 imagepng($imageres, NULL, 0);
             }
         }
     }
     imageInterlace($imageres, 1);
 }
Пример #4
0
 public function interlace($value)
 {
     if (!in_array($this->_format, ['jpeg', 'png', 'gif'])) {
         throw new Exception("Format `{$this->_format}` not supported for interlacing.");
     }
     imageInterlace($this->_object, $value ? 1 : 0);
     return true;
 }
Пример #5
0
 public function interlace($value)
 {
     if (in_array($this->_format, array('jpeg', 'png', 'gif'))) {
         imageInterlace($this->_object, $value ? 1 : 0);
         return true;
     }
     return false;
 }
Пример #6
0
     $file_name = $_FILES['image']['name'];
 } else {
     if (count(explode('.', $_FILES['image']['name'])) > 1) {
         $file_name = explode('.', $_FILES['image']['name']);
         array_pop($file_name);
         $file_name = implode('.', $file_name);
     }
     $file_name .= '.' . $extention;
 }
 if ($_POST['show_or_save'] == 'save') {
     header('Content-Disposition: attachment; filename="' . $file_name . '"');
 }
 header('Cache-Control: no-cache, must-revalidate');
 header('Content-Type: image/jpeg');
 if (isset($_POST['interlace'])) {
     imageInterlace($im, 100);
 }
 if (isset($_POST['resize'])) {
     $scale = false;
     if (isset($_POST['is_scale'])) {
         $scale = true;
     }
     resizeImage($im, $_POST['size_x'], $_POST['size_y'], $scale);
 }
 if (isset($_POST['is_set_quality'])) {
     if ($image_create_fun == 'imagejpeg' || $image_create_fun == 'imagepng') {
         $image_create_fun($im, '', intval($_POST['quality']));
     } else {
         $image_create_fun($im);
     }
 } else {