예제 #1
0
 function SaveImage($im, $filename)
 {
     $res = null;
     // ImageGIF is not included into some GD2 releases, so it might not work
     // output png if gifs are not supported
     if ($this->image_type == 1 && !function_exists('imagegif')) {
         $this->image_type = 3;
     }
     switch ($this->image_type) {
         case 1:
             if ($this->save_to_file) {
                 header("Content-type: image/gif");
                 $res = ImageGIF($im, $filename);
                 $res = ImageGIF($im, NULL);
             } else {
                 header("Content-type: image/gif");
                 $res = ImageGIF($im, $filename);
                 $res = ImageGIF($im, NULL);
             }
             break;
         case 2:
             if ($this->save_to_file) {
                 header("Content-type: image/jpeg");
                 $res = ImageJPEG($im, $filename, $this->quality);
                 $res = ImageJPEG($im, NULL, $this->quality);
             } else {
                 header("Content-type: image/jpeg");
                 $res = ImageJPEG($im, $filename, $this->quality);
                 $res = ImageJPEG($im, NULL, $this->quality);
             }
             break;
         case 3:
             if (PHP_VERSION >= '5.1.2') {
                 // Convert to PNG quality.
                 // PNG quality: 0 (best quality, bigger file) to 9 (worst quality, smaller file)
                 $quality = 9 - min(round($this->quality / 10), 9);
                 if ($this->save_to_file) {
                     header("Content-type: image/png");
                     $res = ImagePNG($im, $filename, $quality);
                     $res = ImagePNG($im, NULL, $quality);
                 } else {
                     header("Content-type: image/png");
                     $res = ImagePNG($im, $filename, $quality);
                     $res = ImagePNG($im, NULL, $quality);
                 }
             } else {
                 if ($this->save_to_file) {
                     header("Content-type: image/png");
                     $res = ImagePNG($im, $filename);
                     $res = ImagePNG($im);
                 } else {
                     header("Content-type: image/png");
                     $res = ImagePNG($im, $filename);
                     $res = ImagePNG($im);
                 }
             }
             break;
     }
     return $res;
 }
예제 #2
0
 /**
  * Функция сохраняет изображение из дескриптора в файл, в соответствии с типом изображения
  * Тип изображения берется из свойств класса
  * 
  * @param (resource) $resImage - дескриптор (идентификатор) изображения
  * @param (string) $newImg - имя файла, в который сохранить изображение (формат: путь/имя_файла)
  * 
  * @return bool
  */
 static function saveImgToFile($resImage, $newImg)
 {
     // определяем тип изображени и сохраняем его в файл
     switch (self::$arrImgSubj['type']) {
         case '1':
             if (@ImageGIF($resImage, $newImg)) {
                 return true;
             } else {
                 self::setError(ERROR_FILE_NOT_SAVED);
                 return false;
             }
             break;
         case '2':
             if (@ImageJPEG($resImage, $newImg, 80)) {
                 return true;
             } else {
                 self::setError(ERROR_FILE_NOT_SAVED);
                 return false;
             }
             break;
         case '3':
             if (@ImagePNG($resImage, $newImg)) {
                 return true;
             } else {
                 self::setError(ERROR_FILE_NOT_SAVED);
                 return false;
             }
             break;
     }
     self::setError(ERROR_FILE_NOT_SAVED);
     return false;
 }
예제 #3
0
 public function resize($width, $height)
 {
     $type = exif_imagetype($this->image);
     if ($type == 2) {
         $images_orig = ImageCreateFromJPEG($this->image);
     } elseif ($type == 3) {
         $images_orig = ImageCreateFromPNG($this->image);
     } elseif ($type == 1) {
         $images_orig = ImageCreateFromGIF($this->image);
     } else {
         return false;
     }
     $photoX = ImagesX($images_orig);
     $photoY = ImagesY($images_orig);
     $images_fin = ImageCreateTrueColor($width, $height);
     ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
     if ($type == 2) {
         ImageJPEG($images_fin, $this->image);
     } elseif ($type == 3) {
         ImagePNG($images_fin, $this->image);
     } elseif ($type == 1) {
         ImageGIF($images_fin, $this->image);
     }
     ImageDestroy($images_orig);
     ImageDestroy($images_fin);
     return true;
 }
예제 #4
0
 function imageout()
 {
     $im = $this->createimagesource();
     $this->setbackgroundcolor($im);
     $this->set_code($im);
     $this->setdistrubecode($im);
     ImageGIF($im);
     ImageDestroy($im);
 }
function twMachThumbnail($serverPfad, $datei, $breiteThumb, $prefix)
{
    // Bild-Datei (mit Pfad)
    $bildDatei = $serverPfad . $datei;
    // wenn dieses Bild nich gefunden wurde: Abbruch
    if (!file_exists($bildDatei)) {
        return false;
    }
    // wenn dieses Bild schon ein Thumbnail ist: Abbruch
    if (substr($datei, 0, strlen($prefix)) == $prefix) {
        //echo $datei. "<br />";
        //echo strlen($prefix). "<br />";
        //echo $prefix. "<br />";
        //echo substr($datei, strlen($prefix)). "<br />";
        //echo "-----<br />";
        return false;
    }
    // Bilddaten zu dieser Bild-Datei
    $bilddaten = getimagesize($bildDatei);
    $imgOrigBreite = $bilddaten[0];
    $imgOrigHoehe = $bilddaten[1];
    $imgOrigTyp = $bilddaten[2];
    // (1=GIF, 2=JPG, 3=PNG, 4=SWF)
    if ($imgOrigBreite < $breiteThumb) {
        $breiteThumb = $imgOrigBreite;
    }
    $Skalierungsfaktor = $imgOrigBreite / $breiteThumb;
    $thumbHoehe = intval($imgOrigHoehe / $Skalierungsfaktor);
    // wenn es ein gif-Bild ist
    if ($imgOrigTyp == 1) {
        $Originalgrafik = ImageCreateFromGIF($bildDatei);
        $Thumbnailgrafik = ImageCreateTrueColor($breiteThumb, $thumbHoehe);
        ImageCopyResized($Thumbnailgrafik, $Originalgrafik, 0, 0, 0, 0, $breiteThumb, $thumbHoehe, $imgOrigBreite, $imgOrigHoehe);
        ImageGIF($Thumbnailgrafik, $serverPfad . $prefix . $datei, 100);
    } elseif ($imgOrigTyp == 2) {
        $Originalgrafik = ImageCreateFromJPEG($bildDatei);
        $Thumbnailgrafik = ImageCreateTrueColor($breiteThumb, $thumbHoehe);
        ImageCopyResized($Thumbnailgrafik, $Originalgrafik, 0, 0, 0, 0, $breiteThumb, $thumbHoehe, $imgOrigBreite, $imgOrigHoehe);
        ///ImageJPEG($Thumbnailgrafik, $pfad."thumb_".$bild);
        ImageJPEG($Thumbnailgrafik, $serverPfad . $prefix . $datei, 100);
    } elseif ($imgOrigTyp == 3) {
        $Originalgrafik = ImageCreateFromPNG($bildDatei);
        $Thumbnailgrafik = ImageCreateTrueColor($breiteThumb, $thumbHoehe);
        ImageCopyResized($Thumbnailgrafik, $Originalgrafik, 0, 0, 0, 0, $breiteThumb, $thumbHoehe, $imgOrigBreite, $imgOrigHoehe);
        ImagePNG($Thumbnailgrafik, $serverPfad . $prefix . $datei, 100);
    } else {
        return false;
    }
    // Speicher leeren
    if ($Originalgrafik) {
        imagedestroy($Originalgrafik);
    }
    if ($Thumbnailgrafik) {
        imagedestroy($Thumbnailgrafik);
    }
}
예제 #6
0
파일: icon.class.php 프로젝트: ramo01/1kapp
 function makeIcon($type = 1)
 {
     //$img_des = ImageCreateTrueColor ( $this->size, $this->size );
     $img_des = ImageCreateTrueColor($this->size, $this->size);
     $background = imagecolorallocate($img_des, 255, 255, 255);
     imagefill($img_des, 0, 0, $background);
     switch ($this->t) {
         case 'gif':
             $img_src = ImageCreateFromGIF($this->path);
             break;
         case 'jpg':
             $img_src = ImageCreateFromJPEG($this->path);
             break;
         case 'png':
             $img_src = ImageCreateFromPNG($this->path);
             break;
     }
     if ($type == 1) {
         imagecopyresampled($img_des, $img_src, 0, 0, ($this->nw - $this->size) / 2, 0, $this->nw, $this->nh, $this->w, $this->h);
     } else {
         imagecopyresampled($img_des, $img_src, 0, 0, 0, ($this->nh - $this->size) / 2, $this->nw, $this->nh, $this->w, $this->h);
     }
     /*
     imageline( $img_des , 0 , 0 , 0 , ($this->size-1) , imagecolorallocate( $img_des , 220 , 220 , 220 )  );
     imageline( $img_des , 0 , ($this->size-1) , ($this->size-1) , ($this->size-1) , imagecolorallocate( $img_des , 220 , 220 , 220 )  );
     imageline( $img_des , ($this->size-1) , ($this->size-1) , ($this->size-1) , 0 , imagecolorallocate( $img_des , 220 , 220 , 220 )  );
     imageline( $img_des , ($this->size-1) , 0 , 0 , 0 , imagecolorallocate( $img_des , 220 , 220 , 220 )  );
     */
     //echo $this->dest ;
     switch ($this->t) {
         case 'gif':
             if (empty($this->dest)) {
                 header("Content-type: image/gif");
                 return ImageGIF($img_des);
             } else {
                 return ImageGIF($img_des, $this->dest);
             }
             break;
         case 'jpg':
             if (empty($this->dest)) {
                 header("Content-type: image/jpeg");
                 return ImageJPEG($img_des);
             } else {
                 return ImageJPEG($img_des, $this->dest);
             }
             break;
         case 'png':
             if (empty($this->dest)) {
                 header("Content-type: image/png");
                 return ImagePNG($img_des);
             } else {
                 return ImagePNG($img_des, $this->dest);
             }
             break;
     }
 }
예제 #7
0
 function createpicture($action)
 {
     foreach ($this->pictures as $this->picture) {
         $imgsize = getimagesize($this->directory . $this->picture);
         $org_width = $imgsize[0];
         $org_height = $imgsize[1];
         $new_width = $this->width;
         // if ( $org_width > $new_width || $org_height > $this->height_max || $action == 'thumb' )  {
         $new_height = $org_height / $org_width * $new_width;
         $imgfile = substr($this->picture, strlen($this->picture) - 3);
         if (preg_match('/".$imgfile."/i', 'jpg') || preg_match('/".$imgfile."/i', 'jpeg')) {
             $org_picture = imagecreatefromjpeg($this->directory . $this->picture);
         } else {
             if (preg_match('/".$imgfile."/i', 'png')) {
                 $org_picture = imagecreatefrompng($this->directory . $this->picture);
             } else {
                 if (preg_match('/".$imgfile."/i', 'gif')) {
                     $org_picture = imagecreatefromgif($this->directory . $this->picture);
                 }
             }
         }
         if ($org_width < $new_width) {
             $new_width = $org_width;
         }
         if ($org_height < $new_height) {
             $new_height = $org_height;
         }
         if ($new_height > $this->height_max) {
             $new_height = $this->height_max;
             $new_width = $new_height / $org_height * $org_width;
         }
         if (!preg_match($imgfile / i, 'gif')) {
             $newpicture = ImageCreateTrueColor($new_width, $new_height);
         } else {
             if (preg_match($imgfile / i, 'gif')) {
                 $newpicture = imagecreate($new_width, $new_height);
             }
         }
         ImageCopyresampled($newpicture, $org_picture, 0, 0, 0, 0, $new_width, $new_height, $org_width, $org_height);
         if (preg_match('/".$imgfile."/i', 'jpg') || preg_match('/".$imgfile."/i', 'jpeg')) {
             ImageJPEG($newpicture, $this->dir_target . $this->picture);
         } else {
             if (preg_match('/".$imgfile."/i', 'png')) {
                 ImagePNG($newpicture, $this->dir_target . $this->picture);
             } else {
                 if (preg_match('/".$imgfile."/i', 'gif')) {
                     ImageGIF($newpicture, $this->dir_target . $this->picture);
                 }
             }
         }
         //   }
     }
 }
예제 #8
0
function create_avatar($imgpath, $thumbpath, $neueBreite, $neueHoehe)
{
    $size = getimagesize($imgpath);
    $breite = $size[0];
    $hoehe = $size[1];
    $RatioW = $neueBreite / $breite;
    $RatioH = $neueHoehe / $hoehe;
    if ($RatioW < $RatioH) {
        $neueBreite = $breite * $RatioW;
        $neueHoehe = $hoehe * $RatioW;
    } else {
        $neueBreite = $breite * $RatioH;
        $neueHoehe = $hoehe * $RatioH;
    }
    $neueBreite = round($neueBreite, 0);
    $neueHoehe = round($neueHoehe, 0);
    if (function_exists('gd_info')) {
        $tmp = gd_info();
        $imgsup = $tmp['GIF Create Support'] ? 1 : 2;
        unset($tmp);
    } else {
        $imgsup = 2;
    }
    if ($size[2] < $imgsup or $size[2] > 3) {
        return false;
    }
    if ($size[2] == 1) {
        $altesBild = imagecreatefromgif($imgpath);
    } elseif ($size[2] == 2) {
        $altesBild = imagecreatefromjpeg($imgpath);
    } elseif ($size[2] == 3) {
        $altesBild = imagecreatefrompng($imgpath);
    }
    if (function_exists('imagecreatetruecolor') and $size[2] != 1) {
        $neuesBild = png_create_transparent($neueBreite, $neueHoehe);
        imagecopyresampled($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
    } elseif (function_exists('imagecreatetruecolor') and $size[2] == 1) {
        $neuesBild = imageCreate($neueBreite, $neueHoehe);
        gif_create_transparent($neuesBild, $altesBild);
        imagecopyresampled($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
    } else {
        $neuesBild = imageCreate($neueBreite, $neueHoehe);
        imageCopyResized($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
    }
    if ($size[2] == 1) {
        ImageGIF($neuesBild, $thumbpath);
    } elseif ($size[2] == 2) {
        ImageJPEG($neuesBild, $thumbpath);
    } elseif ($size[2] == 3) {
        ImagePNG($neuesBild, $thumbpath);
    }
    return true;
}
예제 #9
0
 function imageSaveX($file, $saveFile = "")
 {
     switch ($this->type) {
         case "JPEG":
             ImageJPEG($file, "{$saveFile}", $this->quality);
             break;
         case "PNG":
             ImagePNG($file, "{$saveFile}");
             break;
         case "GIF":
             ImageGIF($file, "{$saveFile}");
             break;
     }
     return true;
 }
예제 #10
0
 public function saveImage($targetPath)
 {
     switch ($this->ext) {
         case 'image/jpg':
         case 'image/jpeg':
             ImageJPEG($this->targetImage, $targetPath);
             break;
         case 'image/gif':
             ImageGIF($this->targetImage, $targetPath);
             break;
         case 'image/png':
             ImagePNG($this->targetImage, $targetPath);
             break;
     }
     ImageDestroy($this->targetImage);
 }
function twMachThumbnail($pfad, $bild, $thumbBreite)
{
    $bildMitPfad = $pfad . $bild;
    // wenn Bild nich gefunden wurde: Abbruch
    if (!file_exists($bildMitPfad)) {
        return false;
    }
    $bilddaten = getimagesize($bildMitPfad);
    $origBreite = $bilddaten[0];
    $origHoehe = $bilddaten[1];
    if ($origBreite < $thumbBreite) {
        $thumbBreite = $origBreite;
    }
    $Skalierungsfaktor = $origBreite / $thumbBreite;
    $thumbHoehe = intval($origHoehe / $Skalierungsfaktor);
    // wenn es ein gif-Bild ist
    if ($bilddaten[2] == 1) {
        $Originalgrafik = ImageCreateFromGIF($bildMitPfad);
        $Thumbnailgrafik = ImageCreateTrueColor($thumbBreite, $thumbHoehe);
        ImageCopyResized($Thumbnailgrafik, $Originalgrafik, 0, 0, 0, 0, $thumbBreite, $thumbHoehe, $origBreite, $origHoehe);
        ImageGIF($Thumbnailgrafik, $pfad . "thumb_" . $bild);
    } elseif ($bilddaten[2] == 2) {
        $Originalgrafik = ImageCreateFromJPEG($bildMitPfad);
        $Thumbnailgrafik = ImageCreateTrueColor($thumbBreite, $thumbHoehe);
        ImageCopyResized($Thumbnailgrafik, $Originalgrafik, 0, 0, 0, 0, $thumbBreite, $thumbHoehe, $origBreite, $origHoehe);
        ///ImageJPEG($Thumbnailgrafik, $pfad."thumb_".$bild);
        ImageJPEG($Thumbnailgrafik, $pfad . "thumb_" . $bild);
    } elseif ($bilddaten[2] == 3) {
        $Originalgrafik = ImageCreateFromPNG($bildMitPfad);
        $Thumbnailgrafik = ImageCreateTrueColor($thumbBreite, $thumbHoehe);
        ImageCopyResized($Thumbnailgrafik, $Originalgrafik, 0, 0, 0, 0, $thumbBreite, $thumbHoehe, $origBreite, $origHoehe);
        ImagePNG($Thumbnailgrafik, $pfad . "thumb_" . $bild);
    } else {
        return false;
    }
    // Speicher leeren
    if ($Originalgrafik) {
        imagedestroy($Originalgrafik);
    }
    if ($Thumbnailgrafik) {
        imagedestroy($Thumbnailgrafik);
    }
}
예제 #12
0
function thumb_creator($source, $filename, $uploaddir)
{
    $extension = "." . getExtension($filename);
    $new_images = "thumb_" . date(YmdHis) . $extension;
    $tmp_img = $source['tmp_name'];
    $src_size = getimagesize($tmp_img);
    $width = 150;
    $height = round($width * $src_size[1] / $src_size[0]);
    if ($src_size['mime'] === 'image/jpeg') {
        $src = imagecreatefromjpeg($tmp_img);
    } else {
        if ($src_size['mime'] === 'image/jpg') {
            $src = imagecreatefromjpeg($tmp_img);
        } else {
            if ($src_size['mime'] === 'image/png') {
                $src = imagecreatefrompng($tmp_img);
            } else {
                if ($src_size['mime'] === 'image/gif') {
                    $src = imagecreatefromgif($tmp_img);
                }
            }
        }
    }
    $photoX = ImagesX($src);
    $photoY = ImagesY($src);
    $images_fin = ImageCreateTrueColor($width, $height);
    ImageCopyResampled($images_fin, $src, 0, 0, 0, 0, $width + 1, $height + 1, $photoX, $photoY);
    if ($src_size['mime'] === 'image/jpeg') {
        ImageJPEG($images_fin, $uploaddir . "/" . $new_images);
    } else {
        if ($src_size['mime'] === 'image/jpg') {
            ImageJPEG($images_fin, $uploaddir . "/" . $new_images);
        } else {
            if ($src_size['mime'] === 'image/png') {
                ImagePNG($images_fin, $uploaddir . "/" . $new_images);
            } else {
                if ($src_size['mime'] === 'image/gif') {
                    ImageGIF($images_fin, $uploaddir . "/" . $new_images);
                }
            }
        }
    }
}
예제 #13
0
 /**
  * Generate barcoe
  * @param  string $barcode Your barcode
  * @return string          Path to the generated image
  */
 public function generate($barcode)
 {
     $im = $this->makeBarcode39($barcode);
     $path = $this->destination;
     $filename = 'c39_' . md5($barcode . time());
     switch ($this->format) {
         case "JPEG":
             $file = $path . $filename . '.jpg';
             imagejpeg($im, $file, $this->quality);
             break;
         case "PNG":
             $file = $path . $filename . '.png';
             imagepng($im, $file);
             break;
         case "GIF":
             $file = $path . $filename . '.gif';
             ImageGIF($im, $file);
             break;
     }
     return $file;
 }
예제 #14
0
function phpAds_GDShowImage(&$im)
{
    global $phpAds_GDImageFormat;
    if ($phpAds_GDImageFormat == '') {
        $phpAds_GDImageFormat = phpAds_GDImageFormat();
    }
    switch ($phpAds_GDImageFormat) {
        case "gif":
            ImageGIF($im);
            break;
        case "jpeg":
            ImageJPEG($im);
            break;
        case "png":
            ImagePNG($im);
            break;
        default:
            break;
            // No GD installed
    }
}
예제 #15
0
파일: gd.php 프로젝트: aberrios/WEBTHESGO
function cs_resample($image, $target, $max_width, $max_height)
{
    $gd_info = gd_info();
    $im_info = array();
    if (file_exists($image)) {
        $im_info = getimagesize($image);
    } else {
        cs_error(__FILE__, 'Image file does not exist: "' . $image . '"');
        return false;
    }
    if ($im_info[2] == 1 and !empty($gd_info["GIF Read Support"])) {
        $src = ImageCreateFromGIF($image);
    } elseif ($im_info[2] == 2 and (!empty($gd_info["JPG Support"]) or !empty($gd_info["JPEG Support"]))) {
        $src = ImageCreateFromJPEG($image);
    } elseif ($im_info[2] == 3 and !empty($gd_info["PNG Support"])) {
        $src = ImageCreateFromPNG($image);
    } else {
        cs_error(__FILE__, 'Image filetype is not supported: "' . $image . '"');
        return false;
    }
    $factor = max($im_info[1] / $max_height, $im_info[0] / $max_width);
    $im_new[0] = floor($im_info[0] / $factor);
    $im_new[1] = floor($im_info[1] / $factor);
    $dst = ImageCreateTrueColor($im_new[0], $im_new[1]);
    ImageAlphaBlending($dst, false);
    ImageSaveAlpha($dst, true);
    ImageCopyResampled($dst, $src, 0, 0, 0, 0, $im_new[0], $im_new[1], $im_info[0], $im_info[1]);
    if ($im_info[2] == 1) {
        $return = ImageGIF($dst, $target) ? 1 : 0;
    } elseif ($im_info[2] == 2) {
        $return = ImageJPEG($dst, $target, 100) ? 1 : 0;
    } elseif ($im_info[2] == 3) {
        $return = ImagePNG($dst, $target) ? 1 : 0;
    } else {
        cs_error(__FILE__, 'Failed to write resampled image file: "' . $target . '"');
        return false;
    }
    return $return;
}
예제 #16
0
function create_thumb($imgpath, $thumbpath, $neueBreite)
{
    $size = getimagesize($imgpath);
    $breite = $size[0];
    $hoehe = $size[1];
    $neueHoehe = intval($hoehe * $neueBreite / $breite);
    if (function_exists('gd_info')) {
        $tmp = gd_info();
        $imgsup = $tmp['GIF Create Support'] ? 1 : 2;
        unset($tmp);
    } else {
        $imgsup = 2;
    }
    if ($size[2] < $imgsup or $size[2] > 3) {
        return FALSE;
    }
    if ($size[2] == 1) {
        $altesBild = imagecreatefromgif($imgpath);
    } elseif ($size[2] == 2) {
        $altesBild = imagecreatefromjpeg($imgpath);
    } elseif ($size[2] == 3) {
        $altesBild = imagecreatefrompng($imgpath);
    }
    if (function_exists('imagecreatetruecolor') and $size[2] != 1) {
        $neuesBild = imagecreatetruecolor($neueBreite, $neueHoehe);
        imagecopyresampled($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
    } else {
        $neuesBild = imageCreate($neueBreite, $neueHoehe);
        imageCopyResized($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
    }
    if ($size[2] == 1) {
        ImageGIF($neuesBild, $thumbpath);
    } elseif ($size[2] == 2) {
        ImageJPEG($neuesBild, $thumbpath);
    } elseif ($size[2] == 3) {
        ImagePNG($neuesBild, $thumbpath);
    }
    return TRUE;
}
예제 #17
0
function createImage($text, $width, $height, $font = 5)
{
    global $fontColor, $bgColor, $lineColor;
    if ($img = @ImageCreate($width, $height)) {
        list($R, $G, $B) = convertRGB($fontColor);
        $fontColor = ImageColorAllocate($img, $R, $G, $B);
        list($R, $G, $B) = convertRGB($bgColor);
        $bgColor = ImageColorAllocate($img, $R, $G, $B);
        list($R, $G, $B) = convertRGB($lineColor);
        $lineColor = ImageColorAllocate($img, $R, $G, $B);
        ImageFill($img, 0, 0, $bgColor);
        for ($i = 0; $i <= $width; $i += 5) {
            @ImageLine($img, $i, 0, $i, $height, $lineColor);
        }
        for ($i = 0; $i <= $height; $i += 5) {
            @ImageLine($img, 0, $i, $width, $i, $lineColor);
        }
        $hcenter = $width / 2;
        $vcenter = $height / 2;
        $x = round($hcenter - ImageFontWidth($font) * strlen($text) / 2);
        $y = round($vcenter - ImageFontHeight($font) / 2);
        ImageString($img, $font, $x, $y, $text, $fontColor);
        if (function_exists('ImagePNG')) {
            header('Content-Type: image/png');
            @ImagePNG($img);
        } else {
            if (function_exists('ImageGIF')) {
                header('Content-Type: image/gif');
                @ImageGIF($img);
            } else {
                if (function_exists('ImageJPEG')) {
                    header('Content-Type: image/jpeg');
                    @ImageJPEG($img);
                }
            }
        }
        ImageDestroy($img);
    }
}
예제 #18
0
function viewImage($img = '')
{
    global $file, $type;
    switch ($type) {
        case 1:
            if ($img && function_exists('ImageGIF')) {
                header('Content-type: image/gif');
                @ImageGIF($img);
            } else {
                if ($img && function_exists('ImagePNG')) {
                    header('Content-type: image/png');
                    @ImagePNG($img);
                } else {
                    header('Content-type: image/gif');
                    readfile($file);
                }
            }
            break;
        case 2:
            header('Content-type: image/jpeg');
            if ($img && function_exists('ImageJPEG')) {
                @ImageJPEG($img);
            } else {
                readfile($file);
            }
            break;
        case 3:
            header('Content-type: image/png');
            if ($img && function_exists('ImagePNG')) {
                @ImagePNG($img);
            } else {
                readfile($file);
            }
            break;
        default:
            echo "{$file} is not an image";
    }
}
예제 #19
0
 public function captcha_make()
 {
     $imgname = "captcha/src.gif";
     $im = ImageCreateFromGIF($imgname);
     //$im = @ImageCreate (100, 50) or die ("Cannot Initialize new GD image stream");
     $filename = "captcha/src/capt.gif";
     $background_color = ImageColorAllocate($im, 255, 255, 255);
     $text_color = ImageColorAllocate($im, 0, 0, 0);
     $string = "";
     $symbols = array("A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "2", "3", "4", "5", "6", "7", "8", "9");
     for ($i = 0; $i < 5; $i++) {
         $string .= $symbols[rand(0, sizeof($symbols) - 1)];
     }
     ImageTTFText($im, 24, 8, 5, 50, $text_color, "captcha/20527.ttf", $string);
     $this->session->set_userdata('cpt', md5(strtolower($string)));
     ImageGIF($im, $filename);
     return $filename;
     //return "zz";
     /*
     $imgname="captcha/src.gif";
     $im = @ImageCreateFromGIF($imgname);
     //$im = @ImageCreate (100, 50) or die ("Cannot Initialize new GD image stream");
     $filename="captcha/cp_".date("dmyHIS").rand(0,99).rand(0,99).".gif";
     $background_color = ImageColorAllocate($im, 255, 255, 255);
     $text_color = ImageColorAllocate($im, 0,0,0);
     $string="";
     $symbols=Array("A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z","2","3","4","5","6","7","8","9");
     for($i=0;$i<5;$i++){
     	$string.=$symbols[rand(0,(sizeof($symbols)-1))];
     }
     ImageTTFText ($im, 24, 8, 5, 50, $text_color, "captcha/20527.ttf",$string);
     $this->session->set_userdata('cpt', md5(strtolower($string)));
     ImageGIF ($im, $filename);
     return $filename;
     //return "zz";
     */
 }
예제 #20
0
 public function CreatThumb($filetype, $tsrc, $dest, $n_width, $n_height)
 {
     if ($filetype == "gif") {
         $im = ImageCreateFromGIF($dest);
         // Original picture width is stored
         $width = ImageSx($im);
         // Original picture height is stored
         $height = ImageSy($im);
         $newimage = imagecreatetruecolor($n_width, $n_height);
         imageCopyResized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
         ImageGIF($newimage, $tsrc);
         chmod("{$tsrc}", 0755);
     }
     if ($filetype == "jpg") {
         $im = ImageCreateFromJPEG($dest);
         // Original picture width is stored
         $width = ImageSx($im);
         // Original picture height is stored
         $height = ImageSy($im);
         $newimage = imagecreatetruecolor($n_width, $n_height);
         imageCopyResized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
         ImageJpeg($newimage, $tsrc);
         chmod("{$tsrc}", 0755);
     }
     if ($filetype == "png") {
         $im = ImageCreateFromPNG($dest);
         // Original picture width is stored
         $width = ImageSx($im);
         // Original picture height is stored
         $height = ImageSy($im);
         $newimage = imagecreatetruecolor($n_width, $n_height);
         imageCopyResized($newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height);
         imagepng($newimage, $tsrc);
         chmod("{$tsrc}", 0755);
     }
 }
예제 #21
0
 function PrintImage()
 {
     // Browser cache stuff submitted by Thiemo Nagel
     if (!$this->browser_cache && !$this->is_inline) {
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT');
         header('Cache-Control: no-cache, must-revalidate');
         header('Pragma: no-cache');
     }
     switch ($this->file_format) {
         case 'png':
             if (!$this->is_inline) {
                 Header('Content-type: image/png');
             }
             if ($this->is_inline && $this->output_file != '') {
                 ImagePng($this->img, $this->output_file);
             } else {
                 ImagePng($this->img);
             }
             break;
         case 'jpg':
             if (!$this->is_inline) {
                 Header('Content-type: image/jpeg');
             }
             if ($this->is_inline && $this->output_file != '') {
                 ImageJPEG($this->img, $this->output_file);
             } else {
                 ImageJPEG($this->img);
             }
             break;
         case 'gif':
             if (!$this->is_inline) {
                 Header('Content-type: image/gif');
             }
             if ($this->is_inline && $this->output_file != '') {
                 ImageGIF($this->img, $this->output_file);
             } else {
                 ImageGIF($this->img);
             }
             break;
         case 'wbmp':
             // wireless bitmap, 2 bit.
             if (!$this->is_inline) {
                 Header('Content-type: image/wbmp');
             }
             if ($this->is_inline && $this->output_file != '') {
                 ImageWBMP($this->img, $this->output_file);
             } else {
                 ImageWBMP($this->img);
             }
             break;
         default:
             $this->PrintError('PrintImage(): Please select an image type!');
             break;
     }
     return TRUE;
 }
예제 #22
0
function thumbnailImage($imageBitsIn, $contentType)
{
    // Create a GD image
    $imageIn = ImageCreateFromString($imageBitsIn);
    // Measure the image
    $inX = ImageSx($imageIn);
    $inY = ImageSy($imageIn);
    // Decide how to scale it
    if ($inX > $inY) {
        $outX = THUMB_SIZE;
        $outY = (int) (THUMB_SIZE * ((double) $inY / $inX));
    } else {
        $outX = (int) (THUMB_SIZE * ((double) $inX / $inY));
        $outY = THUMB_SIZE;
    }
    // Create thumbnail image and fill it with white
    $imageOut = ImageCreateTrueColor($outX, $outY);
    ImageFill($imageOut, 0, 0, ImageColorAllocate($imageOut, 255, 255, 255));
    // Copy / resize the original image into the thumbnail image
    ImageCopyResized($imageOut, $imageIn, 0, 0, 0, 0, $outX, $outY, $inX, $inY);
    // Write the image to a temporary file in the requested format
    $fileOut = tempnam("/tmp", "aws") . ".aws";
    switch ($contentType) {
        case "image/jpg":
            $ret = ImageJPEG($imageOut, $fileOut, 100);
            break;
        case "image/png":
            $ret = ImagePNG($imageOut, $fileOut, 0);
            break;
        case "image/gif":
            $ret = ImageGIF($imageOut, $fileOut);
            break;
        default:
            unlink($fileOut);
            return false;
    }
    // Verify success
    if (!$ret) {
        unlink($fileOut);
        return false;
    }
    // Read the image back in
    $imageBitsOut = file_get_contents($fileOut);
    // Clean up
    unlink($fileOut);
    return $imageBitsOut;
}
예제 #23
0
/**
 * make thumbnail image and save
 */
function thumbnail($file, $save_filename, $max_width = 100, $max_height = 100, $sizeChg = 1)
{
    $img_info = @getimagesize($file);
    //이미지 사이즈를 확인합니다.
    //이미지 타입을 이용해 변수를 재지정해줍니다.
    //------------------------------------------------------
    // Imagetype Constants
    //------------------------------------------------------
    // 1 IMAGETYPE_GIF
    // 2 IMAGETYPE_JPEG
    // 3 IMAGETYPE_PNG
    // 4 IMAGETYPE_SWF
    // 5 IMAGETYPE_PSD
    // 6 IMAGETYPE_BMP
    // 7 IMAGETYPE_TIFF_II (intel byte order)
    // 8 IMAGETYPE_TIFF_MM (motorola byte order)
    // 9 IMAGETYPE_JPC
    // 10 IMAGETYPE_JP2
    // 11 IMAGETYPE_JPX
    // 12 IMAGETYPE_JB2
    // 13 IMAGETYPE_SWC
    // 14 IMAGETYPE_IFF
    // 15 IMAGETYPE_WBMP
    // 16 IMAGETYPE_XBM
    //------------------------------------------------------
    if ($img_info[2] == 1) {
        $src_img = ImageCreateFromGIF($file);
    } elseif ($img_info[2] == 2) {
        $src_img = ImageCreateFromJPEG($file);
    } elseif ($img_info[2] == 3) {
        $src_img = ImageCreateFromPNG($file);
    } elseif ($img_info[2] == 4) {
        $src_img = ImageCreateFromWBMP($file);
    } else {
        return false;
    }
    $img_info = getImageSize($file);
    //원본이미지의 정보를 얻어옵니다
    $img_width = $img_info[0];
    $img_height = $img_info[1];
    $crt_width = $max_width;
    //생성되면 이미지 사이즈
    $crt_height = $max_height;
    //1.가로 세로 원본비율을 맞추고, 남은 영역에 색채워서 정해진 크기로 생성
    if ($sizeChg == 1) {
        if ($img_width / $max_width == $img_height / $max_height) {
            //원본과 썸네일의 가로세로비율이 같은경우
            $dst_x = 0;
            $dst_y = 0;
            $dst_width = $max_width;
            $dst_height = $max_height;
        } elseif ($img_width / $max_width < $img_height / $max_height) {
            //세로에 기준을 둔경우
            $dst_x = ($max_width - $img_width * ($max_height / $img_height)) / 2;
            $dst_y = 0;
            $dst_width = $max_height * ($img_width / $img_height);
            $dst_height = $max_height;
        } else {
            //가로에 기준을 둔경우
            $dst_x = 0;
            $dst_y = ($max_height - $img_height * ($max_width / $img_width)) / 2;
            $dst_width = $max_width;
            $dst_height = $max_width * ($img_height / $img_width);
        }
        //2.가로 세로 원본비율을 맞추고, 남은 영역없이 이미지만 컷 생성
    } else {
        if ($sizeChg == 2) {
            if ($img_width / $max_width == $img_height / $max_height) {
                //원본과 썸네일의 가로세로비율이 같은경우
                $dst_width = $max_width;
                $dst_height = $max_height;
            } elseif ($img_width / $max_width < $img_height / $max_height) {
                //세로에 기준을 둔경우
                $dst_width = $max_height * ($img_width / $img_height);
                $dst_height = $max_height;
            } else {
                //가로에 기준을 둔경우
                $dst_width = $max_width;
                $dst_height = $max_width * ($img_height / $img_width);
            }
            $dst_x = 0;
            $dst_y = 0;
            $crt_width = $dst_width;
            $crt_height = $dst_height;
            //3.가로 세로 원본비율을 맞추지 않고, 정해진 크기대로 생성
        } else {
            $dst_width = $max_width;
            $dst_height = $max_height;
            $dst_x = 0;
            $dst_y = 0;
        }
    }
    $dst_img = imagecreatetruecolor($crt_width, $crt_height);
    //타겟이미지를 생성합니다
    $white = imagecolorallocate($dst_img, 255, 255, 255);
    imagefill($dst_img, 0, 0, $white);
    ImageCopyResized($dst_img, $src_img, $dst_x, $dst_y, 0, 0, $dst_width, $dst_height, $img_width, $img_height);
    //타겟이미지에 원하는 사이즈의 이미지를 저장합니다
    ImageInterlace($dst_img);
    switch ($img_info[2]) {
        case "1":
            ImageGIF($dst_img, $save_filename);
            break;
        case "2":
            ImageJPEG($dst_img, $save_filename);
            break;
        case "3":
            imagealphablending($dst_img, false);
            imagecopyresampled($dst_img, $src_img, $dst_x, $dst_y, 0, 0, $dst_width, $dst_height, $img_width, $img_height);
            //(생성이미지,원소스이미지,시작점X,시작점Y,원본소스상 시작점X,원본소스상 시작점Y,생성이미지너비, 생성이미지높이,원이미지너비,원이미지높이)
            imagesavealpha($dst_img, true);
            ImagePNG($dst_img, $save_filename, 0);
            break;
        case "4":
            ImageWBMP($dst_img, $save_filename);
            break;
    }
    ImageDestroy($dst_img);
    ImageDestroy($src_img);
}
예제 #24
0
    foreach ($per_host as $index => $percent) {
        $week_day++;
        if ($week_day > 6) {
            $week_day -= 7;
        }
        if ($index / 2 == (int) ($index / 2)) {
            $color = imageColorAllocate($img, 249, 243, 70);
            $color2 = imageColorAllocate($img, 242, 226, 42);
            $color3 = imageColorAllocate($img, 226, 210, 34);
        } else {
            $color = imageColorAllocate($img, 11, 215, 252);
            $color2 = imageColorAllocate($img, 7, 203, 239);
            $color3 = imageColorAllocate($img, 7, 187, 219);
        }
        $y1 = round($imageW - $imageW * $percent + 12);
        imageFilledRectangle($img, $x1, $y1, $x2, $y2, $color);
        $points = array(0 => $x1, 1 => $y1, 2 => $x1 + 3, 3 => $y1 - 5, 4 => $x1 + $collW + 3, 5 => $y1 - 5, 6 => $x2, 7 => $y1);
        imageFilledPolygon($img, $points, 4, $color2);
        $points = array(0 => $x2, 1 => $y1, 2 => $x1 + $collW + 3, 3 => $y1 - 5, 4 => $x1 + $collW + 3, 5 => $y2 - 5, 6 => $x2, 7 => $y2);
        imageFilledPolygon($img, $points, 4, $color3);
        // imageTTFtext($img, 7, 90, $x1+8, 50, $colorBlack, BASEDIR.'/assets/fonts/font.ttf', $host_data[$index]);
        imagestringup($img, 1, $x1 + 3, 52, $host_data[$index], $colorBlack);
        imageTTFtext($img, 6, 0, $x1 + 3, 66, $colorBlack, BASEDIR . '/assets/fonts/font.ttf', $arr_week[$week_day]);
        $x1 += $collW;
        $x2 += $collW;
    }
    //Header("Content-type: image/gif");
    ImageGIF($img, BASEDIR . $imagecache);
    ImageDestroy($img);
}
echo '<img src="' . $imagecache . '?' . date_fixed(SITETIME, "dmY") . '" alt="Неделя" /><br /><br />';
 function PrintImage()
 {
     if ($this->browser_cache == 0 && $this->is_inline == 0) {
         //Submitted by Thiemo Nagel
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . 'GMT');
         header('Cache-Control: no-cache, must-revalidate');
         header('Pragma: no-cache');
     }
     switch ($this->file_format) {
         case "png":
             if ($this->is_inline == 0) {
                 Header('Content-type: image/png');
             }
             if ($this->is_inline == 1 && $this->output_file != "") {
                 ImagePng($this->img, $this->output_file);
             } else {
                 ImagePng($this->img);
             }
             break;
         case "jpg":
             if ($this->is_inline == 0) {
                 Header('Content-type: image/jpeg');
             }
             if ($this->is_inline == 1 && $this->output_file != "") {
                 ImageJPEG($this->img, $this->output_file);
             } else {
                 ImageJPEG($this->img);
             }
             break;
         case "gif":
             if ($this->is_inline == 0) {
                 Header('Content-type: image/gif');
             }
             if ($this->is_inline == 1 && $this->output_file != "") {
                 ImageGIF($this->img, $this->output_file);
             } else {
                 ImageGIF($this->img);
             }
             break;
         case "wbmp":
             if ($this->is_inline == 0) {
                 Header('Content-type: image/wbmp');
             }
             if ($this->is_inline == 1 && $this->output_file != "") {
                 ImageWBMP($this->img, $this->output_file);
             } else {
                 ImageWBMP($this->img);
             }
             break;
         default:
             $this->PrintError('Please select an image type!<br />');
             break;
     }
     ImageDestroy($this->img);
     return true;
 }
예제 #26
0
						  
						  }else{//縦写真の場合の処理
						  
							  $new_height_thumb = $imgWidthHeightThumb; //高さ指定px
							  $rate_thumb = $new_height_thumb / $height; //縦横比を算出
							  $new_width_thumb = $rate_thumb * $width;
						  }
						  $new_image_thumb = ImageCreateTrueColor($new_width_thumb, $new_height_thumb);//サムネイル作成
						  ImageCopyResampled($new_image_thumb,$image,0,0,0,0,$new_width_thumb,$new_height_thumb,$width,$height);//サムネイル作成
						  
							if($imgType == 'image/jpeg' || $imgType == 'image/pjpeg'){
								if(!@is_int($img_quality)) $img_quality = 80;//画質に数字以外の無効な文字列が指定されていた場合のデフォルト値
								ImageJPEG($new_image_thumb, $img_file_path_thumb, $img_quality); //サムネイル作成
							}
							elseif($imgType == 'image/gif') {
								ImageGIF($new_image_thumb, $img_file_path_thumb);//サムネイル作成
							}
							elseif($imgType == 'image/png' || $imgType == 'image/x-png') {
								ImagePNG($new_image_thumb, $img_file_path_thumb);//サムネイル作成
							}
						  imagedestroy ($new_image_thumb); //サムネイル元イメージIDの破棄
						}
						//----------------------------------------------------------------------
						//  サムネイル生成処理  (END)
						//----------------------------------------------------------------------
					  
					}
					  @chmod($img_file_path, 0666);
					  @chmod($img_file_path_thumb, 0666);
			
			}else{
예제 #27
0
 function makeThumbWatermark($width = 128, $height = 128)
 {
     $this->fileCheck();
     $image_info = $this->getInfo($this->src_image_name);
     if (!$image_info) {
         return false;
     }
     $src_image_type = $image_info["type"];
     $img = $this->createImage($src_image_type, $this->src_image_name);
     if (!$img) {
         return false;
     }
     $width = $width == 0 ? $image_info["width"] : $width;
     $height = $height == 0 ? $image_info["height"] : $height;
     $width = $width > $image_info["width"] ? $image_info["width"] : $width;
     $height = $height > $image_info["height"] ? $image_info["height"] : $height;
     $srcW = $image_info["width"];
     $srcH = $image_info["height"];
     if ($srcH * $width > $srcW * $height) {
         $width = round($srcW * $height / $srcH);
     } else {
         $height = round($srcH * $width / $srcW);
     }
     //*
     $src_image = @imagecreatetruecolor($width, $height);
     $white = @imagecolorallocate($src_image, 0xff, 0xff, 0xff);
     @imagecolortransparent($src_image, $white);
     @imagefilltoborder($src_image, 0, 0, $white, $white);
     if ($src_image) {
         ImageCopyResampled($src_image, $img, 0, 0, 0, 0, $width, $height, $image_info["width"], $image_info["height"]);
     } else {
         $src_image = imagecreate($width, $height);
         ImageCopyResized($src_image, $img, 0, 0, 0, 0, $width, $height, $image_info["width"], $image_info["height"]);
     }
     $src_image_w = ImageSX($src_image);
     $src_image_h = ImageSY($src_image);
     if ($this->wm_image_name) {
         $wm_image_info = $this->getInfo($this->wm_image_name);
         if (!$wm_image_info) {
             return false;
         }
         $wm_image_type = $wm_image_info["type"];
         $wm_image = $this->createImage($wm_image_type, $this->wm_image_name);
         $wm_image_w = ImageSX($wm_image);
         $wm_image_h = ImageSY($wm_image);
         $temp_wm_image = $this->getPos($src_image_w, $src_image_h, $this->wm_image_pos, $wm_image);
         if ($this->emboss && function_exists("imagefilter")) {
             imagefilter($wm_image, IMG_FILTER_EMBOSS);
             $bgcolor = imagecolorclosest($wm_image, 0x7f, 0x7f, 0x7f);
             imagecolortransparent($wm_image, $bgcolor);
         }
         if (function_exists("ImageAlphaBlending") && IMAGETYPE_PNG == $wm_image_info['type']) {
             ImageAlphaBlending($src_image, true);
         }
         $wm_image_x = $temp_wm_image["dest_x"];
         $wm_image_y = $temp_wm_image["dest_y"];
         if (IMAGETYPE_PNG == $wm_image_info['type']) {
             imageCopy($src_image, $wm_image, $wm_image_x, $wm_image_y, 0, 0, $wm_image_w, $wm_image_h);
         } else {
             imageCopyMerge($src_image, $wm_image, $wm_image_x, $wm_image_y, 0, 0, $wm_image_w, $wm_image_h, $this->wm_image_transition);
         }
     }
     if ($this->wm_text) {
         $this->wm_text = $this->wm_text;
         $temp_wm_text = $this->getPos($src_image_w, $src_image_h, $this->wm_image_pos);
         $wm_text_x = $temp_wm_text["dest_x"];
         $wm_text_y = $temp_wm_text["dest_y"];
         if (preg_match("/([a-f0-9][a-f0-9])([a-f0-9][a-f0-9])([a-f0-9][a-f0-9])/i", $this->wm_text_color, $color)) {
             $red = hexdec($color[1]);
             $green = hexdec($color[2]);
             $blue = hexdec($color[3]);
             $wm_text_color = imagecolorallocate($src_image, $red, $green, $blue);
         } else {
             $wm_text_color = imagecolorallocate($src_image, 255, 255, 255);
         }
         imagettftext($src_image, $this->wm_text_size, $this->wm_angle, $wm_text_x, $wm_text_y, $wm_text_color, $this->wm_text_font, $this->wm_text);
     }
     if ($this->save_file) {
         switch ($src_image_type) {
             case 1:
                 if ($this->gif_enable) {
                     $src_img = ImageGIF($src_image, $this->save_file);
                 } else {
                     $src_img = ImagePNG($src_image, $this->save_file);
                 }
                 break;
             case 2:
                 $src_img = ImageJPEG($src_image, $this->save_file, $this->jpeg_quality);
                 break;
             case 3:
                 $src_img = ImagePNG($src_image, $this->save_file);
                 break;
             default:
                 $src_img = ImageJPEG($src_image, $this->save_file, $this->jpeg_quality);
                 break;
         }
     } else {
         switch ($src_image_type) {
             case 1:
                 if ($this->gif_enable) {
                     header("Content-type: image/gif");
                     $src_img = ImageGIF($src_image);
                 } else {
                     header("Content-type: image/png");
                     $src_img = ImagePNG($src_image);
                 }
                 break;
             case 2:
                 header("Content-type: image/jpeg");
                 $src_img = ImageJPEG($src_image, "", $this->jpeg_quality);
                 break;
             case 3:
                 header("Content-type: image/png");
                 $src_img = ImagePNG($src_image);
                 break;
             case 6:
                 header("Content-type: image/bmp");
                 $src_img = imagebmp($src_image);
                 break;
             default:
                 header("Content-type: image/jpeg");
                 $src_img = ImageJPEG($src_image, "", $this->jpeg_quality);
                 break;
         }
     }
     imagedestroy($src_image);
     imagedestroy($img);
     return true;
 }
예제 #28
0
function OutputImage($im, $format, $quality)
{
    switch ($format) {
        case "JPEG":
            ImageJPEG($im, "", $quality);
            break;
        case "PNG":
            ImagePNG($im);
            break;
        case "GIF":
            ImageGIF($im);
            break;
    }
}
예제 #29
0
 function makeThumbnailtoFile($destFile)
 {
     if (!$this->isWorking()) {
         return false;
     }
     $size = getimagesize($this->sourceFile);
     switch ($size[2]) {
         case IMAGETYPE_JPEG:
             $im_in = @ImageCreateFromJPEG($this->sourceFile);
             break;
         case IMAGETYPE_GIF:
             $im_in = @ImageCreateFromGIF($this->sourceFile);
             break;
         case IMAGETYPE_PNG:
             $im_in = @ImageCreateFromPNG($this->sourceFile);
             break;
         case IMAGETYPE_BMP:
             $im_in = $this->_ImageCreateFromBMP($this->sourceFile);
             break;
         default:
             return false;
     }
     if (!$im_in) {
         return false;
     }
     $im_out = ImageCreateTrueColor($this->thumbWidth, $this->thumbHeight);
     ImageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $this->thumbWidth, $this->thumbHeight, $this->sourceWidth, $this->sourceHeight);
     switch (strtolower($this->thumbSetting['Format'])) {
         case 'png':
             ImagePNG($im_out, $destFile, $this->thumbQuality);
             break;
         case 'gif':
             ImageGIF($im_out, $destFile);
             break;
         case 'jpg':
         case 'jpeg':
         default:
             ImageJPEG($im_out, $destFile, $this->thumbQuality);
             break;
     }
     ImageDestroy($im_in);
     ImageDestroy($im_out);
     return true;
 }
예제 #30
0
 function output()
 {
     if ($this->debug) {
         // for debugging purposes.
         //expandPre($this->graph);
         //expandPre($this->y_data);
         //expandPre($this->x_data);
         //expandPre($this->parameter);
     } else {
         $expiresSeconds = $this->parameter['seconds_to_live'];
         $expiresHours = $this->parameter['hours_to_live'];
         if ($expiresHours || $expiresSeconds) {
             $now = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"));
             $expires = mktime(date("H") + $expiresHours, date("i"), date("s") + $expiresSeconds, date("m"), date("d"), date("Y"));
             $expiresGMT = gmdate('D, d M Y H:i:s', $expires) . ' GMT';
             $lastModifiedGMT = gmdate('D, d M Y H:i:s', $now) . ' GMT';
             Header('Last-modified: ' . $lastModifiedGMT);
             Header('Expires: ' . $expiresGMT);
         }
         if ($this->parameter['file_name'] == 'none') {
             switch ($this->parameter['output_format']) {
                 case 'GIF':
                     Header("Content-type: image/gif");
                     // GIF??. switch to PNG guys!!
                     ImageGIF($this->image);
                     break;
                 case 'JPEG':
                     Header("Content-type: image/jpeg");
                     // JPEG for line art??. included for completeness.
                     ImageJPEG($this->image);
                     break;
                 default:
                     Header("Content-type: image/png");
                     // preferred output format
                     ImagePNG($this->image);
                     break;
             }
         } else {
             switch ($this->parameter['output_format']) {
                 case 'GIF':
                     ImageGIF($this->image, $this->parameter['file_name'] . '.gif');
                     break;
                 case 'JPEG':
                     ImageJPEG($this->image, $this->parameter['file_name'] . '.jpg');
                     break;
                 default:
                     ImagePNG($this->image, $this->parameter['file_name'] . '.png');
                     break;
             }
         }
         ImageDestroy($this->image);
     }
 }