• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imageCreateFromGIF函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中imageCreateFromGIF函数的典型用法代码示例。如果您正苦于以下问题:PHP imageCreateFromGIF函数的具体用法?PHP imageCreateFromGIF怎么用?PHP imageCreateFromGIF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了imageCreateFromGIF函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: initFromPath

 /**
  * Initialize a layer from a given image path
  * 
  * From an upload form, you can give the "tmp_name" path
  * 
  * @param string $path
  * 
  * @return ImageWorkshopLayer
  */
 public static function initFromPath($path)
 {
     if (file_exists($path) && !is_dir($path)) {
         if (!is_readable($path)) {
             throw new ImageWorkshopException('Can\'t open the file at "' . $path . '" : file is not writable, did you check permissions (755 / 777) ?', static::ERROR_NOT_WRITABLE_FILE);
         }
         $imageSizeInfos = @getImageSize($path);
         $mimeContentType = explode('/', $imageSizeInfos['mime']);
         if (!$mimeContentType || !array_key_exists(1, $mimeContentType)) {
             throw new ImageWorkshopException('Not an image file (jpeg/png/gif) at "' . $path . '"', static::ERROR_NOT_AN_IMAGE_FILE);
         }
         $mimeContentType = $mimeContentType[1];
         switch ($mimeContentType) {
             case 'jpeg':
                 $image = imageCreateFromJPEG($path);
                 break;
             case 'gif':
                 $image = imageCreateFromGIF($path);
                 break;
             case 'png':
                 $image = imageCreateFromPNG($path);
                 break;
             default:
                 throw new ImageWorkshopException('Not an image file (jpeg/png/gif) at "' . $path . '"', static::ERROR_NOT_AN_IMAGE_FILE);
                 break;
         }
         return new ImageWorkshopLayer($image);
     }
     throw new ImageWorkshopException('No such file found at "' . $path . '"', static::ERROR_IMAGE_NOT_FOUND);
 }
开发者ID:gdragffy,项目名称:ImageWorkshop,代码行数:39,代码来源:ImageWorkshop.php


示例2: gerar_tumbs_real

function gerar_tumbs_real($t_x, $t_y, $qualidade, $c_original, $c_final)
{
    $thumbnail = imagecreatetruecolor($t_x, $t_y);
    $original = $c_original;
    $igInfo = getImageSize($c_original);
    switch ($igInfo['mime']) {
        case 'image/gif':
            if (imagetypes() & IMG_GIF) {
                $originalimage = imageCreateFromGIF($original);
            } else {
                $ermsg = MSG_GIF_NOT_COMPATIBLE . '<br />';
            }
            break;
        case 'image/jpeg':
            if (imagetypes() & IMG_JPG) {
                $originalimage = imageCreateFromJPEG($original);
            } else {
                $ermsg = MSG_JPG_NOT_COMPATIBLE . '<br />';
            }
            break;
        case 'image/png':
            if (imagetypes() & IMG_PNG) {
                $originalimage = imageCreateFromPNG($original);
            } else {
                $ermsg = MSG_PNG_NOT_COMPATIBLE . '<br />';
            }
            break;
        case 'image/wbmp':
            if (imagetypes() & IMG_WBMP) {
                $originalimage = imageCreateFromWBMP($original);
            } else {
                $ermsg = MSG_WBMP_NOT_COMPATIBLE . '<br />';
            }
            break;
        default:
            $ermsg = $igInfo['mime'] . MSG_FORMAT_NOT_COMPATIBLE . '<br />';
            break;
    }
    $nLargura = $igInfo[0];
    $nAltura = $igInfo[1];
    if ($nLargura > $t_x and $nAltura > $t_y) {
        if ($t_x <= $t_y) {
            $nLargura = (int) ($igInfo[0] * $t_y / $igInfo[1]);
            $nAltura = $t_y;
        } else {
            $nLargura = $t_x;
            $nAltura = (int) ($igInfo[1] * $t_x / $igInfo[0]);
            if ($nAltura < $t_y) {
                $nLargura = (int) ($igInfo[0] * $t_y / $igInfo[1]);
                $nAltura = $t_y;
            }
        }
    }
    $x_pos = $t_x / 2 - $nLargura / 2;
    $y_pos = $t_y / 2 - $nAltura / 2;
    imagecopyresampled($thumbnail, $originalimage, $x_pos, $y_pos, 0, 0, $nLargura, $nAltura, $igInfo[0], $igInfo[1]);
    imagejpeg($thumbnail, $c_final, $qualidade);
    imagedestroy($thumbnail);
    return 'ok';
}
开发者ID:amorimlima,项目名称:Hospital,代码行数:60,代码来源:Thumbs.php


示例3: __construct

 public function __construct($path)
 {
     list($this->width, $this->height, $this->type) = @getImageSize($path);
     if ($this->type == IMAGETYPE_JPEG) {
         $this->image = imageCreateFromJPEG($path);
         $this->extension = 'jpg';
         if (function_exists('exif_read_data')) {
             $this->exif = exif_read_data($path);
         }
         $this->rotateToExifOrientation();
     } else {
         if ($this->type == IMAGETYPE_PNG) {
             $this->image = imageCreateFromPNG($path);
             $this->extension = 'png';
         } else {
             if ($this->type == IMAGETYPE_GIF) {
                 $this->image = imageCreateFromGIF($path);
                 $this->extension = 'gif';
             }
         }
     }
     if ($this->image) {
         $this->valid = true;
     }
 }
开发者ID:Norvares,项目名称:nemex,代码行数:25,代码来源:image.php


示例4: _getImageResource

 private function _getImageResource($image_file, $save = FALSE)
 {
     $image_info = getImageSize($image_file);
     if ($save) {
         $this->_image_mime = $image_info['mime'];
     }
     switch ($image_info['mime']) {
         case 'image/gif':
             if ($save) {
                 $this->_image_type = 'gif';
             }
             $img_rs = imageCreateFromGIF($image_file);
             break;
         case 'image/jpeg':
             if ($save) {
                 $this->_image_type = 'jpeg';
             }
             $img_rs = imageCreateFromJPEG($image_file);
             break;
         case 'image/png':
             if ($save) {
                 $this->_image_type = 'png';
             }
             $img_rs = imageCreateFromPNG($image_file);
             imageAlphaBlending($img_rs, TRUE);
             imageSaveAlpha($img_rs, TRUE);
             break;
     }
     return $img_rs;
 }
开发者ID:EmranAhmed,项目名称:envato-watermark-image-replacement,代码行数:30,代码来源:dummy_Image_Replacement.php


示例5: create_thumb

function create_thumb($path, $thumb_path, $width = THUMB_WIDTH, $height = THUMB_HEIGHT)
{
    $image_info = getImageSize($path);
    // see EXIF for faster way
    switch ($image_info['mime']) {
        case 'image/gif':
            if (imagetypes() & IMG_GIF) {
                // not the same as IMAGETYPE
                $o_im = @imageCreateFromGIF($path);
            } else {
                throw new Exception('GIF images are not supported');
            }
            break;
        case 'image/jpeg':
            if (imagetypes() & IMG_JPG) {
                $o_im = @imageCreateFromJPEG($path);
            } else {
                throw new Exception('JPEG images are not supported');
            }
            break;
        case 'image/png':
            if (imagetypes() & IMG_PNG) {
                $o_im = @imageCreateFromPNG($path);
            } else {
                throw new Exception('PNG images are not supported');
            }
            break;
        case 'image/wbmp':
            if (imagetypes() & IMG_WBMP) {
                $o_im = @imageCreateFromWBMP($path);
            } else {
                throw new Exception('WBMP images are not supported');
            }
            break;
        default:
            throw new Exception($image_info['mime'] . ' images are not supported');
            break;
    }
    list($o_wd, $o_ht, $html_dimension_string) = $image_info;
    $ratio = $o_wd / $o_ht;
    $t_ht = $width;
    $t_wd = $height;
    if (1 > $ratio) {
        $t_wd = round($o_wd * $t_wd / $o_ht);
    } else {
        $t_ht = round($o_ht * $t_ht / $o_wd);
    }
    $t_wd = $t_wd < 1 ? 1 : $t_wd;
    $t_ht = $t_ht < 1 ? 1 : $t_ht;
    $t_im = imageCreateTrueColor($t_wd, $t_ht);
    imageCopyResampled($t_im, $o_im, 0, 0, 0, 0, $t_wd, $t_ht, $o_wd, $o_ht);
    imagejpeg($t_im, $thumb_path, 85);
    chmod($thumb_path, 0664);
    imageDestroy($o_im);
    imageDestroy($t_im);
    return array($t_wd, $t_ht);
}
开发者ID:sztanpet,项目名称:aoiboard,代码行数:57,代码来源:functions.php


示例6: resize_image

 public static function resize_image($path_from, $path_to, $content_ext, $max_width, $max_height)
 {
     //if ($content_ext=='') $content_ext=c_file::get_ext($path_from);
     //else
     $content_ext = mb_strtolower($content_ext);
     $im = '';
     switch ($content_ext) {
         case ".jpg":
         case ".jpeg":
             $im = @imageCreateFromJPEG($path_from);
             break;
         case ".png":
             $im = @imageCreateFromPNG($path_from);
             break;
         case ".gif":
             $im = @imageCreateFromGIF($path_from);
             break;
         default:
             return false;
             break;
     }
     if ($im == '') {
         //may be ext is wrong
         $im = @imageCreateFromJPEG($path_from);
         if ($im == '') {
             $im = @imageCreateFromPNG($path_from);
         }
         if ($im == '') {
             $im = @imageCreateFromGIF($path_from);
         }
     }
     if ($im == '') {
         return false;
     }
     if (ImageSX($im) >= ImageSY($im) && ImageSX($im) > $max_width) {
         $thumb_ratio = ImageSY($im) / (ImageSX($im) / $max_width) / $max_height;
         $im_new_th = @ImageCreateTrueColor($max_width, $max_height);
         @imagecopyresampled($im_new_th, $im, 0, 0, (ImageSX($im) - ImageSX($im) * $thumb_ratio) / 1.5, 0, $max_width, $max_height, ImageSX($im) * $thumb_ratio, ImageSY($im));
         @ImageJPEG($im_new_th, $path_to);
         @ImageDestroy($im_new_th);
     } else {
         if (ImageSY($im) > $max_height) {
             $thumb_ratio = ImageSX($im) / (ImageSY($im) / $max_height) / $max_width;
             $im_new_th = @ImageCreateTrueColor($max_width, $max_height);
             @imagecopyresampled($im_new_th, $im, 0, 0, 0, (ImageSY($im) - ImageSY($im) * $thumb_ratio) / 5, $max_width, $max_height, ImageSX($im), ImageSY($im) * $thumb_ratio);
             @ImageJPEG($im_new_th, $path_to);
             @ImageDestroy($im_new_th);
         } else {
             @ImageJPEG($im, $path_to);
         }
     }
     @ImageDestroy($im);
     c_file::set_chmod_chown_chgrp($path_to);
     return true;
 }
开发者ID:Rabotyahoff,项目名称:xml_engine,代码行数:55,代码来源:c_file.php


示例7: getCanvas

 public function getCanvas()
 {
     if ($this->_canvas == null) {
         switch ($this->_metrics->sourceFormat) {
             case 1:
                 #GIF
                 $this->_canvas = imageCreateFromGIF($this->filePath);
                 break;
             case 2:
                 #JPG
                 $this->_canvas = imageCreateFromJPEG($this->filePath);
                 break;
             case 3:
                 #PNG
                 $this->_canvas = imageCreateFromPNG($this->filePath);
                 break;
         }
     }
     return $this->_canvas;
 }
开发者ID:RhubarbPHP,项目名称:Module.ImageProcessing,代码行数:20,代码来源:Image.php


示例8: get_im

 public static function get_im($src)
 {
     if (empty($src)) {
         return false;
     }
     $info = @getimagesize($src);
     if (is_array($info)) {
         $type_img = $info[2];
         /* 1 = GIF,
            2 = JPG,
            3 = PNG,
            4 = SWF,
            5 = PSD,
            6 = BMP,
            7 = TIFF(intel),
            8 = TIFF(motorola),
            9 = JPC,
            10 = JP2,
            11 = JP*/
         switch ($type_img) {
             case 1:
                 $im = @imageCreateFromGIF($src);
                 break;
             case 2:
                 $im = @imageCreateFromJPEG($src);
                 break;
             case 3:
                 $im = @imageCreateFromPNG($src);
                 break;
             case 6:
                 $im = @imagecreatefromwbmp($src);
                 break;
             default:
                 $im = false;
                 break;
         }
     } else {
         $im = false;
     }
     return $im;
 }
开发者ID:Rabotyahoff,项目名称:xml_engine,代码行数:41,代码来源:c_graph.php


示例9: imageConverter

 function imageConverter()
 {
     /* parse arguments */
     $numargs = func_num_args();
     $imagefile = func_get_arg(0);
     $convertedtype = func_get_arg(1);
     $this->finalFilePath = func_get_arg(2);
     $output = 0;
     if ($numargs > 3) {
         $this->output = func_get_arg(3);
     }
     /* ask the type of original file */
     $fileinfo = pathinfo($imagefile);
     $imtype = $fileinfo["extension"];
     $this->imname = basename($fileinfo["basename"], "." . $imtype);
     $this->imtype = $imtype;
     /* create the image variable of original file */
     switch ($imtype) {
         case "gif":
             $this->im = imageCreateFromGIF($imagefile);
             break;
         case "jpg":
             $this->im = imageCreateFromJPEG($imagefile);
             break;
         case "png":
             $this->im = imageCreateFromPNG($imagefile);
             break;
         case "wbmp":
             $this->im = imageCreateFromWBMP($imagefile);
             break;
             /*
             		mail me if you have/find this functionality bellow  */
             /*
             case "swf":
             	$this->im 	= $this->imageCreateFromSWF($imagefile);
             	break;
             */
     }
     /* convert to intended type */
     $this->convertImage($convertedtype);
 }
开发者ID:hyrmedia,项目名称:modules,代码行数:41,代码来源:class.imageconverter.inc.php


示例10: initFromPath

 /**
  * Initialize a layer from a given image path
  * 
  * From an upload form, you can give the "tmp_name" path
  * 
  * @param string $path
  * @param bool $fixOrientation
  * 
  * @return ImageWorkshopLayer
  */
 public static function initFromPath($path, $fixOrientation = false)
 {
     if (!file_exists($path)) {
         throw new ImageWorkshopException(sprintf('File "%s" not exists.', $path), static::ERROR_IMAGE_NOT_FOUND);
     }
     if (false === ($imageSizeInfos = @getImageSize($path))) {
         throw new ImageWorkshopException('Can\'t open the file at "' . $path . '" : file is not readable, did you check permissions (755 / 777) ?', static::ERROR_NOT_READABLE_FILE);
     }
     $mimeContentType = explode('/', $imageSizeInfos['mime']);
     if (!$mimeContentType || !isset($mimeContentType[1])) {
         throw new ImageWorkshopException('Not an image file (jpeg/png/gif) at "' . $path . '"', static::ERROR_NOT_AN_IMAGE_FILE);
     }
     $mimeContentType = $mimeContentType[1];
     $exif = array();
     switch ($mimeContentType) {
         case 'jpeg':
             $image = imageCreateFromJPEG($path);
             if (false === ($exif = @read_exif_data($path))) {
                 $exif = array();
             }
             break;
         case 'gif':
             $image = imageCreateFromGIF($path);
             break;
         case 'png':
             $image = imageCreateFromPNG($path);
             break;
         default:
             throw new ImageWorkshopException('Not an image file (jpeg/png/gif) at "' . $path . '"', static::ERROR_NOT_AN_IMAGE_FILE);
             break;
     }
     if (false === $image) {
         throw new ImageWorkshopException('Unable to create image with file found at "' . $path . '"');
     }
     $layer = new ImageWorkshopLayer($image, $exif);
     if ($fixOrientation) {
         $layer->fixOrientation();
     }
     return $layer;
 }
开发者ID:everlon,项目名称:ImageWorkshop,代码行数:50,代码来源:ImageWorkshop.php


示例11: toPng

 public function toPng($src, $destroyOriginal = false)
 {
     $parts = explode('.', $src);
     $fileExtension = strtolower(array_pop($parts));
     if ($fileExtension == 'png') {
         return $src;
     }
     if ($fileExtension != 'png') {
         $dest = implode('.', $parts) . '.png';
     } else {
         $dest = $src;
     }
     if ($fileExtension == "jpg" || $fileExtension == 'jpeg') {
         $newImage = ImageCreateFromJpeg($src);
     } elseif ($fileExtension == 'gif') {
         $newImage = imageCreateFromGIF($src);
     }
     imagepng($newImage, $dest);
     imagedestroy($newImage);
     if ($destroyOriginal) {
         unlink($src);
     }
     return $dest;
 }
开发者ID:briceparent,项目名称:Shopsailors,代码行数:24,代码来源:sh_images.cls.php


示例12: initFromPath

 /**
  * Initialize a layer from a given image path
  * 
  * From an upload form, you can give the "tmp_name" path
  * 
  * @param string $path
  * 
  * @return ImageWorkshopLayer
  */
 public static function initFromPath($path)
 {
     if (file_exists($path) && !is_dir($path)) {
         $imageSizeInfos = getImageSize($path);
         $mimeContentType = explode('/', $imageSizeInfos['mime']);
         $mimeContentType = $mimeContentType[1];
         switch ($mimeContentType) {
             case 'jpeg':
                 $image = imageCreateFromJPEG($path);
                 break;
             case 'gif':
                 $image = imageCreateFromGIF($path);
                 break;
             case 'png':
                 $image = imageCreateFromPNG($path);
                 break;
             default:
                 throw new ImageWorkshopException('Not an image file (jpeg/png/gif) at "' . $path . '"', static::ERROR_NOT_AN_IMAGE_FILE);
                 break;
         }
         return new ImageWorkshopLayer($image);
     }
     throw new ImageWorkshopException('No such file found at "' . $path . '"', static::ERROR_IMAGE_NOT_FOUND);
 }
开发者ID:Yatko,项目名称:Gifteng,代码行数:33,代码来源:ImageWorkshop.php


示例13: watermark

 function watermark($target, $watermark_file, $ext, $watermarkstatus = 9, $watermarktrans = 50)
 {
     $gdsurporttype = array();
     if (function_exists('imageAlphaBlending') && function_exists('getimagesize')) {
         if (function_exists('imageGIF')) {
             $gdsurporttype[] = 'gif';
         }
         if (function_exists('imagePNG')) {
             $gdsurporttype[] = 'png';
         }
         if (function_exists('imageJPEG')) {
             $gdsurporttype[] = 'jpg';
             $gdsurporttype[] = 'jpeg';
         }
     }
     if ($gdsurporttype && in_array($ext, $gdsurporttype)) {
         $attachinfo = getimagesize($target);
         $watermark_logo = imageCreateFromGIF($watermark_file);
         $logo_w = imageSX($watermark_logo);
         $logo_h = imageSY($watermark_logo);
         $img_w = $attachinfo[0];
         $img_h = $attachinfo[1];
         $wmwidth = $img_w - $logo_w;
         $wmheight = $img_h - $logo_h;
         $animatedgif = 0;
         if ($attachinfo['mime'] == 'image/gif') {
             $fp = fopen($target, 'rb');
             $targetcontent = fread($fp, 9999999);
             fclose($fp);
             $animatedgif = strpos($targetcontent, 'NETSCAPE2.0') === FALSE ? 0 : 1;
         }
         if ($watermark_logo && $wmwidth > 10 && $wmheight > 10 && !$animatedgif) {
             switch ($attachinfo['mime']) {
                 case 'image/jpeg':
                     $dst_photo = imageCreateFromJPEG($target);
                     break;
                 case 'image/gif':
                     $dst_photo = imageCreateFromGIF($target);
                     break;
                 case 'image/png':
                     $dst_photo = imageCreateFromPNG($target);
                     break;
             }
             switch ($watermarkstatus) {
                 case 1:
                     $x = +5;
                     $y = +5;
                     break;
                 case 2:
                     $x = ($logo_w + $img_w) / 2;
                     $y = +5;
                     break;
                 case 3:
                     $x = $img_w - $logo_w - 5;
                     $y = +5;
                     break;
                 case 4:
                     $x = +5;
                     $y = ($logo_h + $img_h) / 2;
                     break;
                 case 5:
                     $x = ($logo_w + $img_w) / 2;
                     $y = ($logo_h + $img_h) / 2;
                     break;
                 case 6:
                     $x = $img_w - $logo_w;
                     $y = ($logo_h + $img_h) / 2;
                     break;
                 case 7:
                     $x = +5;
                     $y = $img_h - $logo_h - 5;
                     break;
                 case 8:
                     $x = ($logo_w + $img_w) / 2;
                     $y = $img_h - $logo_h;
                     break;
                 case 9:
                     $x = $img_w - $logo_w - 5;
                     $y = $img_h - $logo_h - 5;
                     break;
             }
             imageAlphaBlending($watermark_logo, FALSE);
             imagesavealpha($watermark_logo, TRUE);
             imageCopyMerge($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h, $watermarktrans);
             switch ($attachinfo['mime']) {
                 case 'image/jpeg':
                     imageJPEG($dst_photo, $target);
                     break;
                 case 'image/gif':
                     imageGIF($dst_photo, $target);
                     break;
                 case 'image/png':
                     imagePNG($dst_photo, $target);
                     break;
             }
         }
     }
 }
开发者ID:softhui,项目名称:discuz,代码行数:98,代码来源:upload.class.php


示例14: load_image

 public static function load_image($page, $name, $tmp_path)
 {
     $size = self::ensure_image($page, $name, $tmp_path);
     if (!$size) {
         return null;
     }
     switch ($size[2]) {
         case 1:
             $img = imageCreateFromGIF($tmp_path);
             break;
         case 2:
             $img = imageCreateFromJPEG($tmp_path);
             break;
         case 3:
             $img = imageCreateFromPNG($tmp_path);
             break;
     }
     @unlink($tmp_path);
     return array($img, $size);
 }
开发者ID:restorer,项目名称:deprecated-zame-cms,代码行数:20,代码来源:cms.php


示例15: resize

 /**
  * ฟังก์ชั่นปรับขนาดของภาพ โดยรักษาอัตราส่วนของภาพตามความกว้างที่ต้องการ
  * หากรูปภาพมีขนาดเล็กกว่าที่กำหนด จะเป็นการ copy file
  * หากรูปภาพมาความสูง หรือความกว้างมากกว่า $width
  * จะถูกปรับขนาดให้มีขนาดไม่เกิน $width (ทั้งความสูงและความกว้าง)
  * และเปลี่ยนชนิดของภาพเป็น jpg
  *
  * @param string $source path และชื่อไฟล์ของไฟล์รูปภาพต้นฉบับ
  * @param string $target path ของไฟล์รูปภาพปลายทาง
  * @param string $name ชื่อไฟล์ของรูปภาพปลายทาง
  * @param int $width ขนาดสูงสุดของรูปภาพที่ต้องการ
  * @param string $watermark (optional) ข้อความลายน้ำ
  * @return array|bool คืนค่าแอเรย์ [name, width, height, mime] ของรูปภาพปลายทาง หรือ false ถ้าไม่สามารถดำเนินการได้
  */
 public static function resize($source, $target, $name, $width, $watermark = '')
 {
     $info = @getImageSize($source);
     if ($info[0] > $width || $info[1] > $width) {
         switch ($info['mime']) {
             case 'image/gif':
                 $o_im = imageCreateFromGIF($source);
                 break;
             case 'image/jpg':
             case 'image/jpeg':
             case 'image/pjpeg':
                 $o_im = self::orient($source);
                 break;
             case 'image/png':
             case 'image/x-png':
                 $o_im = imageCreateFromPNG($source);
                 break;
         }
         $o_wd = @imagesx($o_im);
         $o_ht = @imagesy($o_im);
         if ($o_wd <= $o_ht) {
             $h = $width;
             $w = round($h * $o_wd / $o_ht);
         } else {
             $w = $width;
             $h = round($w * $o_ht / $o_wd);
         }
         $t_im = @ImageCreateTrueColor($w, $h);
         @ImageCopyResampled($t_im, $o_im, 0, 0, 0, 0, $w + 1, $h + 1, $o_wd, $o_ht);
         if ($watermark != '') {
             $t_im = self::watermarkText($t_im, $watermark);
         }
         $newname = substr($name, 0, strrpos($name, '.')) . '.jpg';
         if (!@ImageJPEG($t_im, $target . $newname, self::$quality)) {
             $ret = false;
         } else {
             $ret['name'] = $newname;
             $ret['width'] = $w;
             $ret['height'] = $h;
             $ret['mime'] = 'image/jpeg';
         }
         @imageDestroy($o_im);
         @imageDestroy($t_im);
         return $ret;
     } elseif (@copy($source, $target . $name)) {
         $ret['name'] = $name;
         $ret['width'] = $info[0];
         $ret['height'] = $info[1];
         $ret['mime'] = $info['mime'];
         return $ret;
     }
     return false;
 }
开发者ID:goragod,项目名称:kotchasan,代码行数:67,代码来源:Image.php


示例16: imageDefine

 /**
  * function imageDefine (void)
  *
  * Check the image format and create a new image with the same format
  *
  * return resource
  */
 function imageDefine()
 {
     switch ($this->data[2]) {
         case 1:
             return imageCreateFromGIF($this->image);
         case 2:
             return imageCreateFromJPEG($this->image);
         case 3:
             return imageCreateFromPNG($this->image);
         default:
             return false;
     }
 }
开发者ID:vcgato29,项目名称:poff,代码行数:20,代码来源:imageTransform.php


示例17: makeThumbnail

 /** 
  * Creates a thumbnail picture (jpg/png) of a big image
  * 
  * @param	boolean 	$rescale
  * @return	string		thumbnail 
  */
 public function makeThumbnail($rescale = false)
 {
     list($width, $height, $this->imageType) = @getImageSize($this->sourceFile);
     // check image size
     if ($this->checkSize($width, $height, $rescale)) {
         return false;
     }
     // try to extract the embedded thumbnail first (faster)
     $thumbnail = false;
     if (!$rescale && $this->useEmbedded) {
         $thumbnail = $this->extractEmbeddedThumbnail();
     }
     if (!$thumbnail) {
         // calculate uncompressed filesize
         // and cancel to avoid a memory_limit error
         $memoryLimit = self::getMemoryLimit();
         if ($memoryLimit && $memoryLimit != -1) {
             $fileSize = $width * $height * ($this->imageType == 3 ? 4 : 3);
             if ($fileSize * 2.1 + memory_get_usage() > $memoryLimit) {
                 return false;
             }
         }
         // calculate new picture size
         $x = $y = 0;
         if ($this->quadratic) {
             $newWidth = $newHeight = $this->maxWidth;
             if ($this->appendSourceInfo) {
                 $newHeight -= self::$sourceInfoLineHeight * 2;
             }
             if ($width > $height) {
                 $x = ceil(($width - $height) / 2);
                 $width = $height;
             } else {
                 $y = ceil(($height - $width) / 2);
                 $height = $width;
             }
         } else {
             $maxHeight = $this->maxHeight;
             if ($this->appendSourceInfo) {
                 $maxHeight -= self::$sourceInfoLineHeight * 2;
             }
             if ($this->maxWidth / $width < $maxHeight / $height) {
                 $newWidth = $this->maxWidth;
                 $newHeight = round($height * ($newWidth / $width));
             } else {
                 $newHeight = $maxHeight;
                 $newWidth = round($width * ($newHeight / $height));
             }
         }
         // resize image
         $imageResource = false;
         // jpeg image
         if ($this->imageType == 2 && function_exists('imagecreatefromjpeg')) {
             $imageResource = @imageCreateFromJPEG($this->sourceFile);
         }
         // gif image
         if ($this->imageType == 1 && function_exists('imagecreatefromgif')) {
             $imageResource = @imageCreateFromGIF($this->sourceFile);
         }
         // png image
         if ($this->imageType == 3 && function_exists('imagecreatefrompng')) {
             $imageResource = @imageCreateFromPNG($this->sourceFile);
         }
         // could not create image
         if (!$imageResource) {
             return false;
         }
         // resize image
         if (function_exists('imageCreateTrueColor') && function_exists('imageCopyResampled')) {
             $imageNew = @imageCreateTrueColor($newWidth, $newHeight);
             imageAlphaBlending($imageNew, false);
             @imageCopyResampled($imageNew, $imageResource, 0, 0, $x, $y, $newWidth, $newHeight, $width, $height);
             imageSaveAlpha($imageNew, true);
         } else {
             if (function_exists('imageCreate') && function_exists('imageCopyResized')) {
                 $imageNew = @imageCreate($newWidth, $newHeight);
                 imageAlphaBlending($imageNew, false);
                 @imageCopyResized($imageNew, $imageResource, 0, 0, $x, $y, $newWidth, $newHeight, $width, $height);
                 imageSaveAlpha($imageNew, true);
             } else {
                 return false;
             }
         }
         // create thumbnail
         ob_start();
         if ($this->imageType == 1 && function_exists('imageGIF')) {
             @imageGIF($imageNew);
             $this->mimeType = 'image/gif';
         } else {
             if (($this->imageType == 1 || $this->imageType == 3) && function_exists('imagePNG')) {
                 @imagePNG($imageNew);
                 $this->mimeType = 'image/png';
             } else {
                 if (function_exists('imageJPEG')) {
//.........这里部分代码省略.........
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:101,代码来源:Thumbnail.class.php


示例18: Watermark_GD

 function Watermark_GD()
 {
     if (function_exists('imagecopy') && function_exists('imagealphablending') && function_exists('imagecopymerge')) {
         $imagecreatefromfunc = $this->imagecreatefromfunc;
         $imagefunc = $this->imagefunc;
         list($img_w, $img_h) = $this->attachinfo;
         if ($this->watermarktype < 2) {
             //非文本
             $watermark_file = HDWIKI_ROOT . './style/default/watermark/logo.' . ($this->watermarktype == 1 ? 'png' : 'gif');
             $watermarkinfo = @getimagesize($watermark_file);
             $watermark_logo = $this->watermarktype == 1 ? @imageCreateFromPNG($watermark_file) : @imageCreateFromGIF($watermark_file);
             if (!$watermark_logo) {
                 return;
             }
             list($logo_w, $logo_h) = $watermarkinfo;
         } else {
             //水印是文本类型
             $watermarktextcvt = $this->watermarktext['text'];
             $box = imagettfbbox($this->watermarktext['size'], $this->watermarktext['angle'], $this->watermarktext['fontpath'], $watermarktextcvt);
             $logo_h = max($box[1], $box[3]) - min($box[5], $box[7]);
             $logo_w = max($box[2], $box[4]) - min($box[0], $box[6]);
             $ax = min($box[0], $box[6]) * -1;
             $ay = min($box[5], $box[7]) * -1;
         }
         $wmwidth = $img_w - $logo_w;
         $wmheight = $img_h - $logo_h;
         if (($this->watermarktype < 2 && is_readable($watermark_file) || $this->watermarktype == 2) && $wmwidth > 10 && $wmheight > 10 && !$this->animatedgif) {
             switch ($this->watermarkstatus) {
                 case 1:
                     $x = +5;
                     $y = +5;
                     break;
                 case 2:
                     $x = ($img_w - $logo_w) / 2;
                     $y = +5;
                     break;
                 case 3:
                     $x = $img_w - $logo_w - 5;
                     $y = +5;
                     break;
                 case 4:
                     $x = +5;
                     $y = ($img_h - $logo_h) / 2;
                     break;
                 case 5:
                     $x = ($img_w - $logo_w) / 2;
                     $y = ($img_h - $logo_h) / 2;
                     break;
                 case 6:
                     $x = $img_w - $logo_w - 5;
                     $y = ($img_h - $logo_h) / 2;
                     break;
                 case 7:
                     $x = +5;
                     $y = $img_h - $logo_h - 5;
                     break;
                 case 8:
                     $x = ($img_w - $logo_w) / 2;
                     $y = $img_h - $logo_h - 5;
                     break;
                 case 9:
                     $x = $img_w - $logo_w - 5;
                     $y = $img_h - $logo_h - 5;
                     break;
             }
             $dst_photo = imagecreatetruecolor($img_w, $img_h);
             $target_photo = @$imagecreatefromfunc($this->srcfile);
             imageCopy($dst_photo, $target_photo, 0, 0, 0, 0, $img_w, $img_h);
             if ($this->watermarktype == 1) {
                 imageCopy($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h);
             } elseif ($this->watermarktype == 2) {
                 if (($this->watermarktext['shadowx'] || $this->watermarktext['shadowy']) && $this->watermarktext['shadowcolor']) {
                     $shadowcolorrgb = $this->excolor($this->watermarktext['shadowcolor']);
                     $shadowcolor = imagecolorallocate($dst_photo, $shadowcolorrgb[0], $shadowcolorrgb[1], $shadowcolorrgb[2]);
                     imagettftext($dst_photo, $this->watermarktext['size'], $this->watermarktext['angle'], $x + $ax + $this->watermarktext['shadowx'], $y + $ay + $this->watermarktext['shadowy'], $shadowcolor, $this->watermarktext['fontpath'], $watermarktextcvt);
                 }
                 $colorrgb = $this->excolor($this->watermarktext['color']);
                 $color = imagecolorallocate($dst_photo, $colorrgb[0], $colorrgb[1], $colorrgb[2]);
                 imagettftext($dst_photo, $this->watermarktext['size'], $this->watermarktext['angle'], $x + $ax, $y + $ay, $color, $this->watermarktext['fontpath'], $watermarktextcvt);
             } else {
                 imageAlphaBlending($watermark_logo, true);
                 imageCopyMerge($dst_photo, $watermark_logo, $x, $y, 0, 0, $logo_w, $logo_h, $this->watermarktrans);
             }
             if ($this->attachinfo['mime'] == 'image/jpeg') {
                 $imagefunc($dst_photo, $this->targetfile, $this->watermarkquality);
             } else {
                 $imagefunc($dst_photo, $this->targetfile);
             }
         } else {
             return false;
         }
     }
     return true;
 }
开发者ID:meiwenhui,项目名称:hdwiki,代码行数:94,代码来源:watermark.class.php


示例19: edit

	public function edit($path, $crop_x, $crop_y, $crop_w, $crop_h, $target_w, $target_h) {
		$imageSize = @getimagesize($path);
		$img_type = $imageSize[2];
		
		//create "canvas" to put new resized and/or cropped image into
		$image = @imageCreateTrueColor($target_w, $target_h);
		
		switch($img_type) {
			case IMAGETYPE_GIF:
				$im = @imageCreateFromGIF($path);
				break;
			case IMAGETYPE_JPEG:
				$im = @imageCreateFromJPEG($path);
				break;
			case IMAGETYPE_PNG:
				$im = @imageCreateFromPNG($path);
				break;
		}
		
		if ($im) {
			// Better transparency - thanks for the ideas and some code from mediumexposure.com
			if (($img_type == IMAGETYPE_GIF) || ($img_type == IMAGETYPE_PNG)) {
				$trnprt_indx = imagecolortransparent($im);
				
				// If we have a specific transparent color
				if ($trnprt_indx >= 0) {
			
					// Get the original image's transparent color's RGB values
					$trnprt_color = imagecolorsforindex($im, $trnprt_indx);
					
					// Allocate the same color in the new image resource
					$trnprt_indx = imagecolorallocate($image, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
					
					// Completely fill the background of the new image with allocated color.
					imagefill($image, 0, 0, $trnprt_indx);
					
					// Set the background color for new image to transparent
					imagecolortransparent($image, $trnprt_indx);
					
				
				} else if ($img_type == IMAGETYPE_PNG) {
				
					// Turn off transparency blending (temporarily)
					imagealphablending($image, false);
					
					// Create a new transparent color for image
					$color = imagecolorallocatealpha($image, 0, 0, 0, 127);
					
					// Completely fill the background of the new image with allocated color.
					imagefill($image, 0, 0, $color);
					
					// Restore transparency blending
					imagesavealpha($image, true);
			
				}
			}
			
			$res = @imageCopyResampled($image, $im, 0, 0, $crop_x, $crop_y, $target_w, $target_h, $crop_w, $crop_h);
			if ($res) {
				switch($img_type) {
					case IMAGETYPE_GIF:
						$res2 = imageGIF($image, $path);
						break;
					case IMAGETYPE_JPEG:
						$compression = defined('AL_THUMBNAIL_JPEG_COMPRESSION') ? AL_THUMBNAIL_JPEG_COMPRESSION : 80;
						$res2 = imageJPEG($image, $path, $compression);
						break;
					case IMAGETYPE_PNG:
						$res2 = imagePNG($image, $path);
						break;
				}
			}
		}
	}
开发者ID:netconstructor,项目名称:c5_image_cropper,代码行数:74,代码来源:image_cropper.php


示例20: array

 $counts = $querycount->fetchAssoc();
 $host_data = array();
 for ($i = 0, $tekdays = $days; $i < 7; $tekdays--, $i++) {
     $host_data[] = isset($counts[$tekdays]) ? $counts[$tekdays] : 0;
 }
 $host_data = array_reverse($host_data);
 // ---------------------------------------------//
 $max = max($host_data);
 if ($max == 0) {
     $max = 1;
 }
 $per_host = array();
 foreach ($h 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imageCreateFromGif函数代码示例发布时间:2022-05-15
下一篇:
PHP imageCreate函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap