本文整理汇总了PHP中ImageGIF函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageGIF函数的具体用法?PHP ImageGIF怎么用?PHP ImageGIF使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ImageGIF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SaveImage
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: saveImgToFile
/**
* Функция сохраняет изображение из дескриптора в файл, в соответствии с типом изображения
* Тип изображения берется из свойств класса
*
* @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: resize
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: imageout
function imageout()
{
$im = $this->createimagesource();
$this->setbackgroundcolor($im);
$this->set_code($im);
$this->setdistrubecode($im);
ImageGIF($im);
ImageDestroy($im);
}
示例5: twMachThumbnail
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: makeIcon
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: createpicture
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: create_avatar
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: imageSaveX
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: saveImage
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);
}
示例11: twMachThumbnail
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: thumb_creator
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: generate
/**
* 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: phpAds_GDShowImage
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: cs_resample
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;
}