php生成缩略图(文本转换成图形)

 更新时间:2016年11月25日 16:58  点击:1655
这是一款办外开的经典的php生成缩略图类函数,文件灵活实用,可以生成任何风格的图片,并且 可以把文本转换成图形。

copyright   : smart-info limited. all right reserved.
 author      : jacky cheung
 version     : 1.1
 create date : 24 september 2008
 last modify : 15 march 2009
*/

class gd
{
 var $font_face   = "";
 var $text   = "";
 var $size    = 12;
 var $color   = "#000000";
 var $angle   = 0;

 var $width   = 0;
 var $height   = 0;
 var $line_height = 0;
 
 var $type   = "png";
 var $chmod   = 0777;
 var $bg_color  = "#ffffff";
 var $quality  = 95;
 var $antialias  = true;
 
 var $x    = 0;
 var $y    = 0;
 

 /*___| convert text to image |___*/
  public function text2image ( $font_face="", $text="", $attributes=false, $width=0, $all=false )
  {
   $this->font_face  = $font_face;
   $this->text   = $text;
   $this->width  = $width;
   $this->size   = 12;
   $this->color  = "#000000";
   $this->angle  = 0;
   $this->line_height = 0;
   $this->setprop ( $attributes );
   
   if ( $this->width == 0 )
   {
    return $this->convert_text2image ( $this->text, $this->check_text_width( $this->text ) );
   } else {
    // word wrap
    if ( $all === false )
    {
     $text = split(" ", $this->text);
     $text = $this->word_wrap($this->text, $this->width, "<br>");
     $text = split("<br>", $text );
    } else if ( $all === true ) {
     $temp = array();
     for ( $i=0; $i<strlen($this->text); $i++ )
     {
      array_push ( $temp, mb_substr($this->text, $i, 1, "utf-8") );
     }
     $text = array();
     $count_width = 0;
     $i = 0;
     foreach ( $temp as $k => $t )
     {
      $prop = $this->check_text_width($t);
      if ( $count_width + floatval($prop["width"]) < $this->width )
      {
       $text[$i] = $text[$i] . $t;
       $count_width += floatval($prop["width"]);
      } else {
       $count_width = 0;
       $i++;
       $text[$i] = "";
      }
     }
    }
    
    $img = array();
    foreach ( $text as $k => $t )
    {
     $img[$k] = $this->convert_text2image ( $t,  $this->check_text_width( $t ) );
    }
    
    $w = 0;
    $h = 0;
    foreach ( $img as $k => $v )
    {
     $w = (imagesx($img[$k]) > $w) ? imagesx($img[$k]) : $w;

     if ($this->line_height == 0 ) $h += imagesy($img[$k]);
     else $h += ($k < count($img)-1) ? $this->line_height : imagesy($img[$k]);
    }
    
    $base_img = $this->createtransparent($w, $h);
    $locy = 0;
    foreach ( $img as $k => $v )
    {
     if ($k > 0)
     {
      $locy = ($this->line_height == 0) ? $locy + imagesy($img[$k]) : $locy + $this->line_height;
     }
     $base_img = $this->attachgdimage ( $img[$k], $base_img, array ("x"=>0, "y"=>$locy) );
    }
    return $base_img;
   }
  }
  private function word_wrap( $str, $width, $break )
  {
   $formatted = '';
   $position = -1;
   $prev_position = 0;
   $last_line = -1;
   
   /// looping the string stop at each space
   while( $position = mb_stripos( $str, " ", ++$position, 'utf-8' ) ) {
    if( $position > $last_line + $width + 1 ) {
     $formatted.= mb_substr( $str, $last_line + 1, $prev_position - $last_line - 1, 'utf-8' ).$break;
     $last_line = $prev_position;
    }
    $prev_position = $position;
   }
   
   /// adding last line without the break
   $formatted.= mb_substr( $str, $last_line + 1, mb_strlen( $str ), 'utf-8' );
   return $formatted;
  }


  public function convert_text2image ( $text, $prop )
  {
   $im   = imagecreatetruecolor ( $prop["width"], $prop["height"] );
   $rgb   = $this->getrgb ( $this->color );
   $color   = imagecolorallocate ( $im, $rgb["red"], $rgb["green"], $rgb["blue"] );
   $img   = $this->createtransparent ( $prop["width"], $prop["height"] );
   imagettftext ( $img, $this->size, $this->angle, 0, $prop["height"] - abs ( $prop["top"] ), $color, $this->font_face, $text );
   return $img;
  }
  public function check_text_width ( $text )
  {
   $prop = array();
   $bbox    = imagettfbbox ( $this->size, $this->angle, $this->font_face, $text );
   $prop["left"]  = $bbox[0];
   $prop["right"]  = $bbox[2];
   $prop["top"] = $bbox[1];
   $prop["bottom"] = $bbox[7];
   $padding  = 2;
  
   $prop["width"]  = abs($prop["left"]) + abs($prop["right"])  + $padding;
   $prop["height"] = abs($prop["top"])  + abs($prop["bottom"]) + $padding;
   
   return $prop;
  }


 /*___| save to image file |___*/
  public function save($gdimage, $filename, $attributes=false)
  {
   $this->type   = "png";
   $this->chmod   = 0777;
   $this->bg_color  = "#ffffff";
   $this->quality  = 95;
   $this->antialias = true;
   
   $this->setprop ( $attributes );
   
   // process
   switch ( strtolower ( $this->type ) )
   {
    case "jpeg":
    case "jpg":
     $gdimage = $this->createbackground($gdimage, imagesx($gdimage), imagesy($gdimage));
     imagejpeg ( $gdimage, $filename, $this->quality );
     break;
    case "gif":
     $gdimage = $this->createbackground($gdimage, imagesx($gdimage), imagesy($gdimage));
     imagegif ( $gdimage, $filename );
     break;   
    case "png":
    default :
     imagepng ( $gdimage, $filename );
     break;
   }
   chmod ( $filename, $this->chmod );
  }


 /*___| create gd background image |___*/
  public function createbackground($gdimage, $width, $height)
  {
   $img = imagecreatetruecolor ( $width, $height );
   $rgb = $this->getrgb ( $this->bg_color );
   $color = imagecolorallocate ( $img, $rgb["red"], $rgb["green"], $rgb["blue"] );
   imagefill ( $img, 0, 0, $color );
   imagecopyresampled ( $img, $gdimage, 0, 0, 0, 0, $width, $height, $width, $height );
   return $img;
  }


 /*___| create gd transparent image |___*/
  public function createtransparent($width, $height)
  {
   $img = imagecreatetruecolor($width, $height);
   imagealphablending($img, false);
   imagesavealpha($img, true);
   $transparent = imagecolorallocatealpha($img, 0, 0, 0, 127);
   imagefilledrectangle($img, 0, 0, $width, $height, $transparent);
   imagecopyresampled($img, $img, 0, 0, 0, 0, $width, $height, $width, $height);
   return $img;
  }

 
 /*___| load image |___*/
  public function createimagefrom($filename, $alpha=true)
  {
   if ( function_exists ( "exif_imagetype" ) )
   {
    if ( exif_imagetype ( $filename )   == imagetype_jpeg ) { return $this->createfromjpeg ( $filename ); }
    else if ( exif_imagetype ( $filename )  == imagetype_gif  ) { return $this->createfromgif  ( $filename ); }
    else if ( exif_imagetype ( $filename )  == imagetype_png  ) { return $this->createfrompng  ( $filename, $alpha ); }
   }
   else
   {
    if ( strstr ( strtoupper ( $filename )  , ".jpg" )  || strstr ( strtoupper ( $filename ), ".jpeg" )) { return $this->createfromjpeg ( $filename ); }
    else if ( strstr ( strtoupper ( $filename ) , ".gif" )) { return $this->createfromgif ( $filename ); }
    else if ( strstr ( strtoupper ( $filename ) , ".png" )) { return $this->createfrompng ( $filename, $alpha ); }
   }
   return false;
  }
  private function createfromjpeg ( $filename ) { return imagecreatefromjpeg ( $filename ); }
  private function createfromgif  ( $filename ) { return imagecreatefromgif  ( $filename ); }
  private function createfrompng  ( $filename, $alpha=true )
  {
   if ( $alpha )
   {
    list ( $width, $height ) = getimagesize ( $filename );
    $png_img = imagecreatefrompng ( $filename );
    $img = imagecreatetruecolor ( $width, $height );
    imagealphablending ( $img, false );
    imagesavealpha ( $img, true );
    imagecopyresampled ( $img, $png_img, 0, 0, 0, 0, $width, $height, $width, $height );
   } else {
    $img = imagecreatefrompng ( $filename );
   } 
   return $img;
  }
 
 
 /*___| attach background image |___*/
  public function attachbackgroundimage ( $gdimage, $filename, $attributes=false )
  {
   $this->x = 0;
   $this->y = 0;
   $this->setprop ( $attributes );
  
   $img = $this->createimagefrom ( $filename );
   imagecopyresampled ( $img, $gdimage, $this->x, $this->y, 0, 0, imagesx($gdimage), imagesy($gdimage), imagesx($gdimage), imagesy($gdimage) );
   return $img;
  }


 /*___| attach image |___*/
  public function attachimage ( $source, $target, $filename, $image_attributes=false, $attributes=false )
  {
   $source_img = $this->createimagefrom ( $source );
   $target_img = $this->attachbackgroundimage ( $source_img, $target, $attributes );
   $this->save ( $target_img, $filename, $image_attributes );
  }
  
 
 /*___| attach gd image resource |___*/
  public function attachgdimage ( $gd_source, $gd_target, $attributes=false )
  {
   $this->x  = 0;
   $this->y  = 0;
   $this->width = 0;
   $this->height = 0;
   $this->setprop ( $attributes );
   
   imagealphablending($gd_target, true );
   imagealphablending($gd_source, true );
   imagecopy ( $gd_target, $gd_source, $this->x, $this->y, 0, 0, imagesx($gd_source), imagesy($gd_source) );
   return $gd_target;
  }
 
 
 /*___| get rgb color |___*/
  public function getrgb($hex)
  {
   $rgb["red"]   = hexdec ( substr ( $hex, 1, 2 ) ) ;
   $rgb["green"] = hexdec ( substr ( $hex, 3, 2 ) ) ;
   $rgb["blue"]  = hexdec ( substr ( $hex, 5, 2 ) ) ;
   return $rgb;
  }
 
 
 /*___| set properties |___*/ 
  private function setprop ( $attributes=false )
  {
   if ( $attributes ) { foreach  ( $attributes as $key => $value ) { $k = strtoupper ( $key ); $this->$k = $value; } }
  }
}

//调用 方法

 代码如下 复制代码
$imgresize = new imagetransform();
$imgresize->sourcefile = $source.$file;
$imgresize->targetfile = $destination.$file;
$imgresize->chmodvalue = 0777; 
$imgresize->resizetowidth = $tw;
$imgresize->resizetoheight = $th;
$imgresize->jpegoutputquality = 100;
$imgresize->resizeifsmaller = false;
$imgresize->resize();

?>

这是一款图象缩略函数哦,把上传的新图片给$srcfile然后进行文件按$thumbwidth 缩小图宽最大尺寸 与$thumbheitht 缩小图高最大尺寸 生成小图。

图象缩略函数
参数说明:

 代码如下 复制代码
$srcfile 原图地址;
$dir  新图目录
$thumbwidth 缩小图宽最大尺寸
$thumbheitht 缩小图高最大尺寸
$ratio 默认等比例缩放 为1是缩小到固定尺寸。
*/
function makethumb($srcfile,$dir,$thumbwidth,$thumbheight,$ratio=0)
{
 //判断文件是否存在
if (!file_exists($srcfile))return false;
 //生成新的同名文件,但目录不同
$imgname=explode('/',$srcfile);
$arrcount=count($imgname);
$dstfile = $dir.$imgname[$arrcount-1];
//缩略图大小
$tow = $thumbwidth;
$toh = $thumbheight;
if($tow < 40) $tow = 40;
if($toh < 45) $toh = 45;   
 //获取图片信息
    $im ='';
    if($data = getimagesize($srcfile)) {
        if($data[2] == 1) {
            $make_max = 0;//gif不处理
            if(function_exists("imagecreatefromgif")) {
                $im = imagecreatefromgif($srcfile);
            }
        } elseif($data[2] == 2) {
            if(function_exists("imagecreatefromjpeg")) {
                $im = imagecreatefromjpeg($srcfile);
            }
        } elseif($data[2] == 3) {
            if(function_exists("imagecreatefrompng")) {
                $im = imagecreatefrompng($srcfile);
            }
        }
    }
    if(!$im) return '';
    $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($ratio){
        $ftow = $tow;
        $ftoh = $toh;
    }
    //缩小图片
    if($srcw > $tow || $srch > $toh || $ratio) {
        if(function_exists("imagecreatetruecolor") && function_exists("imagecopyresampled") && @$ni = imagecreatetruecolor($ftow, $ftoh)) {
            imagecopyresampled($ni, $im, 0, 0, 0, 0, $ftow, $ftoh, $srcw, $srch);
        } elseif(function_exists("imagecreate") && function_exists("imagecopyresized") && @$ni = imagecreate($ftow, $ftoh)) {
            imagecopyresized($ni, $im, 0, 0, 0, 0, $ftow, $ftoh, $srcw, $srch);
        } else {
            return '';
        }
        if(function_exists('imagejpeg')) {
            imagejpeg($ni, $dstfile);
        } elseif(function_exists('imagepng')) {
            imagepng($ni, $dstfile);
        }
    }else {
        //小于尺寸直接复制
    copy($srcfile,$dstfile);
    }
    imagedestroy($im);
    if(!file_exists($dstfile)) {
        return '';
    } else {
        return $dstfile;
    }
}

?>

本文章收藏了四款关于利用php 等比例缩小图片代码函数,我们可定义图片宽度或高度对图片缩小或放大的图片宽度哦,好了看看四款实例那一款适合于你吧。
 代码如下 复制代码

function imageresize2($width, $height, $targetw, $targeth)
{
  $percentage = 1;
  if (($width > $targetw) || ($height > $targeth))
  {
 $width_diff = $width - $targetw;
 $height_diff = $height - $targeth;
 
 if ($width_diff >= $height_diff)
 {
  $percentage = ($targetw / $width);
 }
 else
 {
  $percentage = ($targeth / $height);
 }
  }
 //gets the new value and applies the percentage, then rounds the value
 $width = round($width * $percentage);
 $height = round($height * $percentage);
 $resize[0] = $width;
 $resize[1] = $height;
 return $resize;
}

//方法二

if (!$max_width)  
  $max_width = 240;  
if (!$max_height)  
  $max_height = 200;  
 
$size = getimagesize($image);  
$width = $size[0];  
$height = $size[1];  
 
$x_ratio = $max_width / $width;  
$y_ratio = $max_height / $height;  
 
if ( ($width <= $max_width) && ($height <= $max_height) ) {  
  $tn_width = $width;  
  $tn_height = $height;  
}  
else if (($x_ratio * $height) < $max_height) {  
  $tn_height = ceil($x_ratio * $height);  
  $tn_width = $max_width;  
}  
else {  
  $tn_width = ceil($y_ratio * $width);  
  $tn_height = $max_height;  
}  
 
$src = imagecreatefrompng($image);  
$dst = imagecreate($tn_width,$tn_height);  
imagecopyresized($dst, $src, 0, 0, 0, 0,  
    $tn_width,$tn_height,$width,$height);  
header("content-type: image/png");  
imagepng($dst, null, -1);  
imagedestroy($src);  
imagedestroy($dst);  

//方法三

/*
函数原型如下:
参数说明:
$oldwidth:原图片宽度
$oldheight:原图片高度
$imgwidth:缩小或放大的图片宽度
$imgheight:缩小或放大的图片高度
返回:wwww.111cn.net
数组:arraysize ,其中索引为:width 和height 即:arraysize['width']、arraysize['height']
*/
function getimgsize($oldwidth,$oldheight,$imgwidth,$imgheight)
{
//$oldwidth设置的宽度,$oldheight设置的高度,$imgwidth图片的宽度,$imgheight图片的高度;

//单元格装得能装得进图片,则按图片的真实大小显示;
if($imgwidth<=$oldwidth&&$imgheight<=$oldheight)
{
$arraysize=array('width'=>$imgwidth,'height'=>$imgheight);
return $arraysize;
}
else
{
$suoxiaowidth=$imgwidth-$oldwidth;
$suoxiaoheight=$imgheight-$oldheight;
$suoxiaoheightper=$suoxiaoheight/$imgheight;
$suoxiaowidthper=$suoxiaowidth/$imgwidth;
if($suoxiaoheightper>=$suoxiaowidthper)
{
//单元格高度为准;
$aftersuoxiaowidth=$imgwidth*(1-$suoxiaoheightper);
$arraysize=array('width'=>$aftersuoxiaowidth,'height'=>$oldheight);
return $arraysize;
}
else
{
//单元格宽度为准;
$aftersuoxiaoheight=$imgheight*(1-$suoxiaowidthper);
$arraysize=array('width'=>$oldwidth,'height'=>$aftersuoxiaoheight);
return $arraysize;
}
}
}

?>

 代码如下 复制代码

//adv0.jpg就是背景图片,注意函数与图片格式对应  
$im = imagecreatefromjpeg('/www/law/images/demo/adv0.jpg');   
$font_color = imagecolorallocate ($im, 0, 250, 10); //这是文字颜色,绿色  
 
$text = "张三的博客";                               //文字内容  
 
$font_file = "/www/font/hyi_xkj.ttf";               //字体的linux绝对路径  
 
//26:字体, 0 是角度, 10,36是坐标, $font_color是文字色, font是字体,  文本是填入的文字  
imagettftext($im, 26,0, 10, 36, $font_color ,$font_file, $text);  往图片插入文字  
 
// output image  
header ('content-type: image/png');                 //即便是从jpg拷贝的图片,也能以png输出,  
imagepng ($im);  
// clean up  
imagedestroy($im);


生成水印方法二

 代码如下 复制代码

public final class imageutils {
public imageutils() {

}

public final static string getpressimgpath(){
return applicationcontext.getrealpath("/template/data/util/shuiyin.gif");
}

/**
* 把图片印刷到图片上
* @param pressimg -- 水印文件
* @param targetimg -- 目标文件
* @param x
* @param y
*/
public final static void pressimage(string pressimg, string targetimg, int x, int y) {
try {
file _file = new file(targetimg);
image src = imageio.read(_file);
int wideth = src.getwidth(null);
int height = src.getheight(null);
bufferedimage image = new bufferedimage(wideth, height,
bufferedimage.type_int_rgb);
graphics g = image.creategraphics();
g.drawimage(src, 0, 0, wideth, height, null);

// 水印文件
file _filebiao = new file(pressimg);
image src_biao = imageio.read(_filebiao);
int wideth_biao = src_biao.getwidth(null);
int height_biao = src_biao.getheight(null);
g.drawimage(src_biao, wideth - wideth_biao - x, height - height_biao -y, wideth_biao,
height_biao, null);
// /
g.dispose();
fileoutputstream out = new fileoutputstream(targetimg);
jpegimageencoder encoder = jpegcodec.createjpegencoder(out);
encoder.encode(image);
out.close();
} catch (exception e) {
e.printstacktrace();
}
}

/**
* 打印文字水印图片
* @param presstext --文字
* @param targetimg -- 目标图片
* @param fontname -- 字体名
* @param fontstyle -- 字体样式
* @param color -- 字体颜色
* @param fontsize -- 字体大小
* @param x -- 偏移量
* @param y
*/

public static void presstext(string presstext, string targetimg, string fontname,int fontstyle, int color, int fontsize, int x, int y) {
try {
file _file = new file(targetimg);
image src = imageio.read(_file);
int wideth = src.getwidth(null);
int height = src.getheight(null);
bufferedimage image = new bufferedimage(wideth, height,
bufferedimage.type_int_rgb);
graphics g = image.creategraphics();
g.drawimage(src, 0, 0, wideth, height, null);
// string s=www.111cn.net;
g.setcolor(color.red);
g.setfont(new font(fontname, fontstyle, fontsize));


g.drawstring(presstext, wideth - fontsize - x, height - fontsize/2 - y);
g.dispose();
fileoutputstream out = new fileoutputstream(targetimg);
jpegimageencoder encoder = jpegcodec.createjpegencoder(out);
encoder.encode(image);
out.close();
} catch (exception e) {
system.out.println(e);
}
}

public static void main(string[] args) {
pressimage("c:/shuiyin/shuiyin.gif", "c:/shuiyin/dsc02342.jpg", 20 ,20);
}
}

php 图片水印中文乱码解决方法是要转入一款中文字体摩洛哥 以了,如果你在生成水印有中文时,又没载入相关的字体的话,那中文肯定会是乱码的,如果是英语字母那载不载入都没关系哦。
 代码如下 复制代码
$name =  iconv("gb2312","utf-8",www.111cn.net 一聚教程网);
$font = 'simhei.ttf';//水印字体  
$im = imagecreatefromjpeg("test.jpg");//载入图片  
$black = imagecolorallocate($im, 0, 0, 0);//设置颜色  
imagettftext($im, 12, 0, 320, 84, $black, $font, $name);//打印水印  
imagepng($im);//输出图片,如果要保存加个保存路径和文件名,如imagepng($im,'test1.jpg');  
imagedestroy($im);//清空缓存 


下面来看一款生成水印文字函数

 代码如下 复制代码

function str2pic ($string,$source,$destination="",$f,$fontsize=10,$shadowcolor="#ffffff",$f,$x=10,$y=10) {  
 //header('content-type:image/png');
    $pi=pathinfo($source);
    $pie=$pi[extension];#获取扩展名
    if(eregi("jpg|jpeg",$pie))$im=@imagecreatefromjpeg($source);
    if(eregi("gif",$pie))$im=@imagecreatefromgif($source);
    if(eregi("png",$pie))$im=@imagecreatefrompng($source);
    $col1=hex2dec($shadowcolor);#阴影颜色
    $col2=hex2dec($fontcolor);#字体颜色
    $col1=imagecolorallocate($im,$col1[0],$col1[1],$col1[2]);
    $col2=imagecolorallocate($im,$col2[0],$col2[1],$col2[2]);
    imagettftext($im,$fontsize,0,$y+1,$x+1,$col1,$fonturl,$string);
    imagettftext($im,$fontsize,0,$y,$x,$col2,$fonturl,$string);
    imagejpeg($im);
    if($destination)imagejpeg($im,$destination);
    imagedestroy($im);
}

function hex2dec($hexcolror) {#十六进制颜色转换成10进制颜色
    preg_match_all("/([0-f]){2,2}/i",$hexcolror,$matches);
    if(count($matches[0])==3){
    $rr=hexdec($matches[0][0]);
    $gg=hexdec($matches[0][1]);
    $bb=hexdec($matches[0][2]);
    }
    return array($rr,$gg,$bb);
}
?>
<?php
str2pic("[url=http://www.111cn.net]www.111cn.net","winter.jpg","winter2.jpg","simhei.ttf",10,"ffffff","330099",10,10[/url]);
?>

 

[!--infotagslink--]

相关文章

  • PS怎么排除重叠图形

    PS排除重叠形状是什么意思?很多朋友都不是很清楚,其实方法很简单的,下面小编就为大家介绍介绍一下,不会的朋友可以参考本文,来看看吧。 步骤:1、在PS中,选择“矩形工具...2016-12-31
  • c#生成高清缩略图的二个示例分享

    这篇文章主要介绍了c#生成高清缩略图的二个示例,需要的朋友可以参考下...2020-06-25
  • R语言学习ggplot2绘制统计图形包全面详解

    这篇文章主要为大家详细介绍了R语言学习ggplot2绘制统计图形包的全面知识讲解,有需要的朋友可以借鉴参考下,希望能够有所帮助...2021-11-06
  • vivo x9怎么设置图形解锁?vivo x9设置图形解锁教程

    本篇文章介绍了vivo x9如何设置图形解锁的教程,手机小白们快来看一看吧。 问:vivo x9怎么设置图形解锁? 答:图形解锁在某种程度上会保护我们的隐私,那么怎么设置图形...2017-01-22
  • PHP批量生成图片缩略图(1/5)

    这款批量生成缩略图代码可以生成指定大小的小图哦,并且支持文件批量上传。 这款教程会用到php文件 view.php config.php funs.php index.php 功能: -------...2016-11-25
  • C#实现为一张大尺寸图片创建缩略图的方法

    这篇文章主要介绍了C#实现为一张大尺寸图片创建缩略图的方法,涉及C#创建缩略图的相关图片操作技巧,需要的朋友可以参考下...2020-06-25
  • php 上传文件并生成缩略图代码

    if( isset($_FILES['upImg']) ) { if( $userGroup[$loginArr['group']]['upload'] == 0 ) { echo '{"error":"您所在的用户组无权上传图片!"}'; } else...2016-11-25
  • CentOS下编译安装nginx及配置缩略图插件的方法教程

    这篇文章主要给大家介绍了在CentOS系统下编译安装nginx及配置缩略图插件的方法教程,文中给出了详细的安装步骤,对大家具有一定的参考价值,有需要的朋友们下面来一起看看吧。...2017-07-06
  • 基于Echarts 3.19 制作常用的图形(非静态)

    这篇文章主要介绍了基于Echarts 3.19 制作常用的图形(非静态)的相关资料,需要的朋友可以参考下...2016-05-20
  • oppo r9s怎么设置和取消图形解锁?oppo r9s设置和取消图形解锁教程

    本篇文章介绍的是oppo r9s如何设置和取消图形解锁的方法,有需要的小伙伴快来看一看吧。 问:oppo r9s怎么设置和取消图形解锁?答:很多朋友都喜欢设置图形解锁,但是不知...2017-01-22
  • c#多图片上传并生成缩略图的实例代码

    今天写了一个上传多张图片并生成缩略图的小程序。当然因为是菜鸟,所以写的一般。但还是学到了不少东西。现在上代码。...2021-09-22
  • 关于Python可视化Dash工具之plotly基本图形示例详解

    这篇文章主要介绍了关于Python可视化Dash工具之plotly基本图形示例详解,需要的朋友可以参考下...2021-03-21
  • Nginx配合php实现生成实时缩略图功能

    这篇文章主要介绍了Nginx配合php实现生成实时缩略图功能,这在一些特殊场合可能会要用到,需要的朋友可以参考下...2016-01-27
  • js通过canvas生成图片缩略图

    对于生成缩略图一般做法是通过后端语言php等来生成,但是为了给服务器减压,我们或许可以从前端来着手,先生成好不同尺寸的缩略图,传给后端,而后端只需要将前端传过来的图片进行存储就好了...2020-10-03
  • php 图片上传代码(具有生成缩略图与增加水印功能)

    这款图片上传源代码是一款可以上传图片并且还具有给上传的图片生成缩略图与增加水印功能哦,可以说是一款完美的图片上传类哦。 代码如下 复制代码 ...2016-11-25
  • C# jpg缩略图函数代码

    生成jpg缩略图字节,本人的小软件中需要用到的功能,所以自己做了一个函数,和大家分享 为什么要生成字节而不是文件,这是为了方便后续处理啦^_^...2020-06-25
  • C#实现判断图形文件格式的方法

    这篇文章主要介绍了C#实现判断图形文件格式的方法,包括常见的扩展名判定及文件内容判定等,非常实用,需要的朋友可以参考下...2020-06-25
  • php支持生成缩略图文件上传代码

    <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1...2016-11-25
  • C#获取视频某一帧的缩略图的方法

    这篇文章主要介绍了C#获取视频某一帧的缩略图的方法,涉及执行CMD命令及针对视频文件操作的技巧,具有一定的实用价值,需要的朋友可以参考下...2020-06-25
  • php利用Imagick把pdf生成png缩略图

    缩略图如果是图片我们直接使用php gD库就可实现了,本文章要介绍的是Imagick把pdf生成png缩略图方法,这里我们要利用一个插件了,下面我来给大家演示一个实例。 php_im...2016-11-25