本文整理汇总了PHP中ImageCreateFromGIF函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageCreateFromGIF函数的具体用法?PHP ImageCreateFromGIF怎么用?PHP ImageCreateFromGIF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ImageCreateFromGIF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cropBilde
private function cropBilde($sti, $filnavn, $nyttFilnavn, $cropBredde, $cropHoyde)
{
$gammeltBilde = $sti . $filnavn;
$bi = @ImageCreateFromJPEG($gammeltBilde) or $bi = @ImageCreateFromPNG($gammeltBilde) or $bi = @ImageCreateFromGIF($gammeltBilde) or $bi = false;
if ($bi) {
$naStorrelse = @getimagesize($gammeltBilde);
$bredde = $naStorrelse[0];
$hoyde = $naStorrelse[1];
$nyBreddeNy = $bredde / $cropBredde;
$nyHoydeNy = $hoyde / $cropHoyde;
$halvertHoyde = $cropHoyde / 2;
$halvertBredde = $cropBredde / 2;
$thumb = @ImageCreateTrueColor($cropBredde, $cropHoyde);
if ($bredde > $hoyde) {
$tilpassetBredde = $bredde / $nyHoydeNy;
$halvBredde = $tilpassetBredde / 2;
$intBredde = $halvBredde - $halvertBredde;
@ImageCopyResampled($thumb, $bi, -$intBredde, 0, 0, 0, $tilpassetBredde, $cropHoyde, $bredde, $hoyde);
} elseif ($bredde < $hoyde || $bredde == $hoyde) {
$tilPassetHoyde = $hoyde / $nyBreddeNy;
$halvHoyde = $tilPassetHoyde / 2;
$intHoyde = $halvHoyde - $halvertHoyde;
@ImageCopyResampled($thumb, $bi, 0, -$intHoyde, 0, 0, $cropBredde, $tilPassetHoyde, $bredde, $hoyde);
} else {
@ImageCopyResampled($thumb, $bi, 0, 0, 0, 0, $cropBredde, $cropHoyde, $bredde, $hoyde);
}
@imagejpeg($thumb, $sti . $nyttFilnavn, 50);
return $nyttFilnavn;
} else {
return -1;
}
}
示例2: open_image
function open_image($file = null)
{
$image_type = $this->image_type($file);
if (!$image_type) {
trigger_error("Invalid image file: {$file}.", E_USER_ERROR);
}
$this->type = $image_type[0];
$this->width = $image_type[1];
$this->height = $image_type[2];
if (!in_array($this->type, $this->supported_img_types)) {
trigger_error("File type '{$this->type}' not supported.", E_USER_ERROR);
}
// Destroy if already open
if ($this->image) {
ImageDestroy($this->image);
}
switch ($this->type) {
case 'JPG':
$this->image = ImageCreateFromJPEG($file);
break;
case 'GIF':
$this->image = ImageCreateFromGIF($file);
break;
case 'PNG':
$this->image = ImageCreateFromPNG($file);
break;
}
}
示例3: SetVar
function SetVar($srcFile, $echoType)
{
if (!file_exists($srcFile)) {
echo '源图片文件不存在!';
exit;
}
$this->srcFile = $srcFile;
$this->echoType = $echoType;
$info = "";
$data = GetImageSize($this->srcFile, $info);
switch ($data[2]) {
case 1:
if (!function_exists("imagecreatefromgif")) {
echo "你的GD库不能使用GIF格式的图片,请使用Jpeg或PNG格式!<a href='javascript:go(-1);'>返回</a>";
exit;
}
$this->im = ImageCreateFromGIF($this->srcFile);
break;
case 2:
if (!function_exists("imagecreatefromjpeg")) {
echo "你的GD库不能使用jpeg格式的图片,请使用其它格式的图片!<a href='javascript:go(-1);'>返回</a>";
exit;
}
$this->im = ImageCreateFromJpeg($this->srcFile);
break;
case 3:
$this->im = ImageCreateFromPNG($this->srcFile);
break;
}
$this->srcW = ImageSX($this->im);
$this->srcH = ImageSY($this->im);
}
示例4: _addWaterMark
/**
* Agrega una marca de agua a la foto
* @param string $absolutePath
*/
private function _addWaterMark($absolutePath)
{
$DOC_ROOT = $this->_CI->input->server('DOCUMENT_ROOT') . "/";
if (FALSE === is_file($absolutePath)) {
return FALSE;
}
switch (TRUE) {
case stristr($absolutePath, 'jpg'):
$photoImage = ImageCreateFromJpeg("{$absolutePath}");
break;
case stristr($absolutePath, 'gif'):
$photoImage = ImageCreateFromGIF("{$absolutePath}");
break;
case stristr($absolutePath, 'png'):
$photoImage = ImageCreateFromPNG("{$absolutePath}");
break;
}
ImageAlphaBlending($photoImage, true);
// Añadimos aquà el fichero de marca de agua.
$logoImage = ImageCreateFromPNG($DOC_ROOT . "assets/imagenes/marca_agua_telam.png");
$logoW = ImageSX($logoImage);
$logoH = ImageSY($logoImage);
$tamanox = imagesx($photoImage);
$ubicacionX = ($tamanox - $logoW) / 2;
$tamanoy = imagesy($photoImage);
$ubicacionY = ($tamanoy - $logoH) / 2;
ImageCopy($photoImage, $logoImage, $ubicacionX, $ubicacionY, 0, 0, $logoW, $logoH);
imagejpeg($photoImage, $absolutePath);
ImageDestroy($photoImage);
ImageDestroy($logoImage);
}
示例5: get_hex
function get_hex($location, $extensions = array('PNG', 'png', 'Png', 'JPG', 'jpg', 'Jpg', 'JPEG', 'jpeg', 'Jpeg', 'GIF', 'gif', 'Gif'), $postvar = "myimage", $getvar = "imgclix")
{
if (isset($_GET[$getvar])) {
foreach ($extensions as $var) {
if (file_exists($location . str_replace(array("..", ".", $var), '', html_entity_decode($_GET[$getvar])) . "." . $var)) {
if (stristr($var, 'png')) {
$im = ImageCreateFromPng($location . str_replace(array("..", ".", $var), '', html_entity_decode($_GET[$getvar])) . "." . $var);
} elseif (stristr($var, 'gif')) {
$im = ImageCreateFromGIF($location . str_replace(array("..", ".", $var), '', html_entity_decode($_GET[$getvar])) . "." . $var);
} elseif (stristr($var, 'jpg') || stristr($var, 'jpeg')) {
$im = ImageCreateFromJpeg($location . str_replace(array("..", ".", $var), '', html_entity_decode($_GET[$getvar])) . "." . $var);
} else {
return FALSE;
}
$rgb = ImageColorAt($im, $_POST[$postvar . '_x'], $_POST[$postvar . '_y']);
$rgb = imagecolorsforindex($im, $rgb);
$hex = sprintf('#%02X%02X%02X', $rgb['red'], $rgb['green'], $rgb['blue']);
break;
}
}
} else {
return FALSE;
}
if (!isset($hex) || $hex == '') {
return FALSE;
}
return $hex;
}
示例6: thumbnail
/**
* @private
*/
function thumbnail($imgfile)
{
//detect image format
$this->img["format"] = ereg_replace(".*\\.(.*)\$", "\\1", $imgfile);
$this->img["format"] = strtoupper($this->img["format"]);
if ($this->img["format"] == "JPG" || $this->img["format"] == "JPEG") {
$this->img["format"] = "JPEG";
$this->img["src"] = @ImageCreateFromJPEG($imgfile);
} elseif ($this->img["format"] == "PNG") {
$this->img["format"] = "PNG";
$this->img["src"] = @ImageCreateFromPNG($imgfile);
} elseif ($this->img["format"] == "GIF") {
$this->img["format"] = "GIF";
if (function_exists("imagecreatefromgif")) {
$this->img["src"] = @ImageCreateFromGIF($imgfile);
} else {
return false;
}
} else {
// not a recognized format
throw new Exception("Trying to generate a thumbnail of an unsupported format!");
//die();
}
// check for errors
if (!$this->img["src"]) {
return false;
}
// if no errors, continue
@($this->img["lebar"] = imagesx($this->img["src"]));
@($this->img["tinggi"] = imagesy($this->img["src"]));
//default quality jpeg
$this->img["quality"] = 85;
return true;
}
示例7: 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;
}
示例8: SetVar
function SetVar($srcFile, $echoType)
{
$this->srcFile = $srcFile;
$this->echoType = $echoType;
$info = '';
$data = GetImageSize($this->srcFile, $info);
switch ($data[2]) {
case 1:
if (!function_exists('imagecreatefromgif')) {
exit;
}
$this->im = ImageCreateFromGIF($this->srcFile);
break;
case 2:
if (!function_exists('imagecreatefromjpeg')) {
exit;
}
$this->im = ImageCreateFromJpeg($this->srcFile);
break;
case 3:
$this->im = ImageCreateFromPNG($this->srcFile);
break;
}
$this->srcW = ImageSX($this->im);
$this->srcH = ImageSY($this->im);
}
示例9: makeThumb1
/**
* 把图片生成缩略图1
* @param string $srcFile 源文件
* @param string $dstFile 目标文件
* @param int $dstW 目标图片宽度
* @param int $dstH 目标文件高度
* @param string $dstFormat 目标文件生成的格式, 有png和jpg两种格式
* @return 错误返回错误对象
*/
public static function makeThumb1($srcFile, $dstFile, $dstW, $dstH, $dstFormat = "png")
{
//打开图片
$data = GetImageSize($srcFile, &$info);
switch ($data[2]) {
case 1:
$im = @ImageCreateFromGIF($srcFile);
break;
case 2:
$im = @imagecreatefromjpeg($srcFile);
break;
case 3:
$im = @ImageCreateFromPNG($srcFile);
break;
}
if (!$im) {
throw new TM_Exception(__CLASS__ . ": Create image failed");
}
//设定图片大小
$srcW = ImageSX($im);
$srcH = ImageSY($im);
$ni = ImageCreate($dstW, $dstH);
ImageCopyResized($ni, $im, 0, 0, 0, 0, $dstW, $dstH, $srcW, $srcH);
//生成指定格式的图片
if ($dstFormat == "png") {
imagepng($ni, $dstFile);
} elseif ($dstFormat == "jpg") {
ImageJpeg($ni, $dstFile);
} else {
imagepng($ni, $dstFile);
}
}
示例10: thumbnail
function thumbnail($PicPathIn, $PicPathOut, $PicFilenameIn, $PicFilenameOut, $neueHoehe, $Quality)
{
// Bilddaten ermitteln
$size = getimagesize("{$PicPathIn}" . "{$PicFilenameIn}");
$breite = $size[0];
$hoehe = $size[1];
$neueBreite = intval($breite * $neueHoehe / $hoehe);
if ($size[2] == 1) {
// GIF
$altesBild = ImageCreateFromGIF("{$PicPathIn}" . "{$PicFilenameIn}");
$neuesBild = imageCreateTrueColor($neueBreite, $neueHoehe);
imageCopyResized($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
imageJPEG($neuesBild, "{$PicPathOut}" . "{$PicFilenameOut}", $Quality);
}
if ($size[2] == 2) {
// JPG
$altesBild = ImageCreateFromJPEG("{$PicPathIn}" . "{$PicFilenameIn}");
$neuesBild = imageCreateTrueColor($neueBreite, $neueHoehe);
imageCopyResized($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
ImageJPEG($neuesBild, "{$PicPathOut}" . "{$PicFilenameOut}", $Quality);
}
if ($size[2] == 3) {
// PNG
$altesBild = ImageCreateFromPNG("{$PicPathIn}" . "{$PicFilenameIn}");
$neuesBild = imageCreateTrueColor($neueBreite, $neueHoehe);
imageCopyResized($neuesBild, $altesBild, 0, 0, 0, 0, $neueBreite, $neueHoehe, $breite, $hoehe);
ImageJPEG($neuesBild, "{$PicPathOut}" . "{$PicFilenameOut}", $Quality);
}
}
示例11: thumbnail
private function thumbnail($imgfile)
{
//detect image format
$this->acHWArr = getimagesize($imgfile);
$this->img["format"] = ereg_replace(".*\\.(.*)\$", "\\1", $imgfile);
$this->img["format"] = strtoupper($this->img["format"]);
if ($this->img["format"] == "JPG" || $this->img["format"] == "JPEG") {
//JPEG
$this->img["format"] = "JPEG";
$this->img["src"] = ImageCreateFromJPEG($imgfile);
} elseif ($this->img["format"] == "PNG") {
//PNG
$this->img["format"] = "PNG";
$this->img["src"] = ImageCreateFromPNG($imgfile);
} elseif ($this->img["format"] == "GIF") {
//GIF
$this->img["format"] = "GIF";
$this->img["src"] = ImageCreateFromGIF($imgfile);
} elseif ($this->img["format"] == "WBMP") {
//WBMP
$this->img["format"] = "WBMP";
$this->img["src"] = ImageCreateFromWBMP($imgfile);
} else {
//DEFAULT
echo "Not Supported File <a href='" . $_SERVER[HTTP_REFERER] . "'>Back</a>";
exit;
}
@($this->img["lebar"] = imagesx($this->img["src"]));
@($this->img["tinggi"] = imagesy($this->img["src"]));
//default quality jpeg
$this->img["quality"] = 75;
}
示例12: thumbnail
function thumbnail($imgfile, $format = "image/jpeg")
{
//detect image format
$pos = strpos($format, "/");
$this->img["format"] = strtoupper(substr($format, $pos + 1));
//$this->img["format"]=ereg_replace(".*\.(.*)$","\\1",$imgfile);
//$this->img["format"]=strtoupper($this->img["format"]);
if ($this->img["format"] == "JPG" || $this->img["format"] == "JPEG") {
//JPEG
$this->img["format"] = "JPEG";
$this->img["src"] = ImageCreateFromJPEG($imgfile);
} elseif ($this->img["format"] == "PNG") {
//PNG
$this->img["format"] = "PNG";
$this->img["src"] = ImageCreateFromPNG($imgfile);
} elseif ($this->img["format"] == "GIF") {
//GIF
$this->img["format"] = "GIF";
$this->img["src"] = ImageCreateFromGIF($imgfile);
} elseif ($this->img["format"] == "WBMP") {
//WBMP
$this->img["format"] = "WBMP";
$this->img["src"] = ImageCreateFromWBMP($imgfile);
} else {
//DEFAULT
echo "Not Supported File ";
$this->is_img = false;
return;
//exit();
}
@($this->img["lebar"] = imagesx($this->img["src"]));
@($this->img["tinggi"] = imagesy($this->img["src"]));
//default quality jpeg
$this->img["quality"] = 75;
}
示例13: thumbnail
function thumbnail($imgfile)
{
//detect image format
//$this->img["format"]=ereg_replace(".*\.(.*)$","\\1",$imgfile);
$this->img["format"] = preg_replace('/.*\\.(.*)$/', "\\1", $imgfile);
$this->img["format"] = strtoupper($this->img["format"]);
if ($this->img["format"] == "JPG" || $this->img["format"] == "JPEG") {
//JPEG
$this->img["format"] = "JPEG";
$this->img["src"] = ImageCreateFromJPEG($imgfile);
} elseif ($this->img["format"] == "PNG") {
//PNG
$this->img["format"] = "PNG";
$this->img["src"] = ImageCreateFromPNG($imgfile);
} elseif ($this->img["format"] == "GIF") {
//GIF
$this->img["format"] = "GIF";
$this->img["src"] = ImageCreateFromGIF($imgfile);
} elseif ($this->img["format"] == "WBMP") {
//WBMP
$this->img["format"] = "WBMP";
$this->img["src"] = ImageCreateFromWBMP($imgfile);
} else {
//DEFAULT
echo "Not Supported File";
exit;
}
@($this->img["lebar"] = imagesx($this->img["src"]));
@($this->img["tinggi"] = imagesy($this->img["src"]));
//default quality jpeg
$this->img["quality"] = 75;
}
示例14: ImageResize
function ImageResize($srcFile, $toW, $toH, $toFile = "")
{
if ($toFile == "") {
$toFile = $srcFile;
}
$info = "";
$data = GetImageSize($srcFile, $info);
switch ($data[2]) {
case 1:
if (!function_exists("imagecreatefromgif")) {
echo "你的GD库不能使用GIF格式的图片,请使用Jpeg或PNG格式!<a href='javascript:go(-1);'>返回</a>";
exit;
}
$im = ImageCreateFromGIF($srcFile);
break;
case 2:
if (!function_exists("imagecreatefromjpeg")) {
echo "你的GD库不能使用jpeg格式的图片,请使用其它格式的图片!<a href='javascript:go(-1);'>返回</a>";
exit;
}
$im = ImageCreateFromJpeg($srcFile);
break;
case 3:
$im = ImageCreateFromPNG($srcFile);
break;
}
$srcW = ImageSX($im);
$srcH = ImageSY($im);
$toWH = $toW / $toH;
$srcWH = $srcW / $srcH;
if ($toWH <= $srcWH) {
$ftoW = $toW;
$ftoH = $ftoW * ($srcH / $srcW);
} else {
$ftoH = $toH;
$ftoW = $ftoH * ($srcW / $srcH);
}
if ($srcW > $toW || $srcH > $toH) {
if (function_exists("imagecreatetruecolor")) {
@($ni = ImageCreateTrueColor($ftoW, $ftoH));
if ($ni) {
ImageCopyResampled($ni, $im, 0, 0, 0, 0, $ftoW, $ftoH, $srcW, $srcH);
} else {
$ni = ImageCreate($ftoW, $ftoH);
ImageCopyResized($ni, $im, 0, 0, 0, 0, $ftoW, $ftoH, $srcW, $srcH);
}
} else {
$ni = ImageCreate($ftoW, $ftoH);
ImageCopyResized($ni, $im, 0, 0, 0, 0, $ftoW, $ftoH, $srcW, $srcH);
}
if (function_exists('imagejpeg')) {
ImageJpeg($ni, $toFile);
} else {
ImagePNG($ni, $toFile);
}
ImageDestroy($ni);
}
ImageDestroy($im);
}
示例15: 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;
}
}