php上传图片并生成缩位图代码

 更新时间:2016年11月25日 16:58  点击:1180

php上传图片并生成缩位图代码,我们时常要上传图片,但也要保留自己的版权所以就会用到图片加水印哦,下面的程序就是上传图片成功后再给图片加上你自己做的水印效果哦.

<?php

class Image {
 var $imageResource = NULL;
 var $target = NULL;
 var $enableTypes = array();
 var $imageInfo = array();
 var $createFunc = '';
 var $imageType = NULL;
 
 /**
  * Construct for this class
  *
  * @param string $image
  * @return Image
  */
 function Image($image = NULL) {
  //get enables
  if(imagetypes() & IMG_GIF) {
   $this->enableTypes[] = 'image/gif';
  }
  if(imagetypes() & IMG_JPEG) {
   $this->enableTypes[] = 'image/jpeg';
  }
  if (imagetypes() & IMG_JPG) {
   $this->enableTypes[] = 'image/jpg';
  }
  if(imagetypes() & IMG_PNG) {
   $this->enableTypes[] = 'image/png';
  }
  //end get
  
  if($image != NULL) {
   $this->setImage($image);
  }
 }
 
 /**
  * set a image resource
  *
  * @param string $image
  * @return boolean
  */
 function setImage($image) {
  if(file_exists($image) && is_file($image)) {
   $this->imageInfo = getimagesize($image);
   $img_mime = strtolower($this->imageInfo['mime']);
   if(!in_array($img_mime, $this->enableTypes)) {
    exit('系统不能操作这种图片类型.');
   }
   switch ($img_mime) {
    case 'image/gif':
     $link = imagecreatefromgif($image);
     $this->createFunc = 'imagegif';
     $this->imageType = 'gif';
     break;
    case 'image/jpeg':
    case 'image/jpg':
     $link = imagecreatefromjpeg($image);
     $this->createFunc = 'imagejpeg';
     $this->imageType = 'jpeg';
     break;
    case 'image/png':
     $link = imagecreatefrompng($image);
     $this->createFunc = 'imagepng';
     $this->imageType = 'png';
     break;
    default:
     $link = 'unknow';
     $this->imageType = 'unknow';
     break;
   }
   if($link !== 'unknow') {
    $this->imageResource = $link;
   } else {
    exit('这种图片类型不能改变尺寸.');
   }
   unset($link);
   return true;
  } else {
   return false;
  }
 }
 
 /**
  * set header
  *
  */
 function setHeader() {
  switch ($this->imageType) {
   case 'gif':
    header('content-type:image/gif');
    break;
   case 'jpeg':
    header('content-type:image/jpeg');
    break;
   case 'png':
    header('content-type:image/png');
    break;
   default:
    exit('Can not set header.');
    break;
  }
  return true;
 }
 
 /**
  * change the image size
  *
  * @param int $width
  * @param int $height
  * @return boolean
  */
 function changeSize($width, $height = -1) {
  if(!is_resource($this->imageResource)) {
   exit('不能改变图片的尺寸,可能是你没有设置图片来源.');
  }
  $s_width = $this->imageInfo[0];
  $s_height = $this->imageInfo[1];
  $width = intval($width);
  $height = intval($height);
  
  if($width <= 0) exit('图片宽度必须大于零.');
  if($height <= 0) {
   $height = ($s_height / $s_width) * $width;
  }
  
  $this->target = imagecreatetruecolor($width, $height);
  if(@imagecopyresized($this->target, $this->imageResource, 0, 0, 0, 0, $width, $height, $s_width, $s_height))
   return true;
  else
   return false;
 }
 
 /**
  * Add watermark
  *
  * @param string $image
  * @param int $app
  */
 function addWatermark($image, $app = 50) {
  if(file_exists($image) && is_file($image)) {
   $s_info = getimagesize($image);
  } else {
   exit($image . '文件不存在.');
  }

  $r_width = $s_info[0];
  $r_height = $s_info[1];

  if($r_width > $this->imageInfo[0]) exit('水印图片必须小于目标图片');
  if($r_height > $this->imageInfo[1]) exit('水印图片必须小于目标图片');
  
  switch ($s_info['mime']) {
   case 'image/gif':
    $resource = imagecreatefromgif($image);
    break;
   case 'image/jpeg':
   case 'image/jpg':
    $resource = imagecreatefromjpeg($image);
    break;
   case 'image/png':
    $resource = imagecreatefrompng($image);
    break;
   default:
    exit($s_info['mime'] .'类型不能作为水印来源.');
    break;
  }
  
  $this->target = &$this->imageResource;
  imagecopymerge($this->target, $resource, $this->imageInfo[0] - $r_width - 5, $this->imageInfo[1] - $r_height - 5, 0,0 ,$r_width, $r_height, $app);
  imagedestroy($resource);
  unset($resource);
 }
 
 /**
  * create image
  *
  * @param string $name
  * @return boolean
  */
 function create($name = NULL) {
  $function = $this->createFunc;
  if($this->target != NULL && is_resource($this->target)) {
   if($name != NULL) {
    $function($this->target, $name);
   } else {
    $function($this->target);
   }
   return true;
  } else if($this->imageResource != NULL && is_resource($this->imageResource)) {
   if($name != NULL) {
    $function($this->imageResource, $name);
   } else {
    $function($this->imageResource);
   }
   return true;
  } else {
   exit('不能创建图片,原因可能是没有设置图片来源.');
  }
 }
 
 /**
  * free resource
  *
  */
 function free() {
  if(is_resource($this->imageResource)) {
   @imagedestroy($this->imageResource);
  }
  if(is_resource($this->target)) {
   @imagedestroy($this->target);
  }
 }
}
?>

php 图处理函数实例教程, 图片处理,php,图片函数

<?php
//公用函数

//把角度转换为弧度
function deg2Arc($degrees) {
return($degrees * (pi()/180.0));
}

//RGB
function getRGB($color){
  $R=($color>>16) & 0xff;
  $G=($color>>8) & 0xff;
  $B=($color) & 0xff;
  return (array($R,$G,$B));
}

// 取得在椭圆心为(0,0)的椭圆上 x,y点的值
function pie_point($deg,$va,$vb){
$x= cos(deg2Arc($deg)) * $va;
$y= sin(deg2Arc($deg)) * $vb;
return (array($x, $y));
}


//3D饼图类

class chart{

var $a; //椭圆长半轴
var $b; //椭圆短半轴
var $DataArray;  //每个扇形的数据
var $ColorArray; //每个扇形的颜色 要求按照十六进制书写但前面不加0x
//为边缘及阴影为黑色

function chart($pa=100,$pb=60,$sData="100,200,300,400,500,300", $sColor="ee00ff,dd0000,cccccc,ccff00,00ccff,ccff00")
{
    $this->a=$pa;
    $this->b=$pb;
    $this->DataArray=split(",",$sData);
    $this->ColorArray=split(",",$sColor);
}

function setA($v){
    $this->a=$v;
}

function getA(){
    return $this->a;
}

function setB($v){
    $this->b=$v; 
}

function getB(){
    return $this->b;
}

function setDataArray($v){
    $this->DataArray=split(",",$v);
}

function getDataArray($v){
    return $this->DataArray;
}

function setColorArray($v){
    $this->ColorArray=split(",",$v);
}

function getColorArray(){
    return  $this->ColorArray;
}

 
function  DrawPie(){
    $image=imagecreate($this->a*2+40,$this->b*2+40);
    $PieCenterX=$this->a+10;
    $PieCenterY=$this->b+10;
    $DoubleA=$this->a*2;
    $DoubleB=$this->b*2;
    list($R,$G,$B)=getRGB(0);
    $colorBorder=imagecolorallocate($image,$R,$G,$B);
    $DataNumber=count($this->DataArray);
    
    //$DataTotal
    for($i=0;$i<$DataNumber;$i++)      $DataTotal+=$this->DataArray[$i]; //算出数据和
    
    //填充背境
    imagefill($image, 0, 0, imagecolorallocate($image, 0xFF, 0xFF, 0xFF));

    /*
    ** 画每一个扇形
    */
    $Degrees = 0;
    for($i = 0; $i < $DataNumber; $i++){
        $StartDegrees = round($Degrees);
        $Degrees += (($this->DataArray[$i]/$DataTotal)*360);
        $EndDegrees = round($Degrees);
        $percent = number_format($this->DataArray[$i]/$DataTotal*100, 1); 
        list($R,$G,$B)=getRGB(hexdec($this->ColorArray[$i]));
        $CurrentColor=imagecolorallocate($image,$R,$G,$B);
        if ($R>60 and $R<256)            $R=$R-60;
        if ($G>60 and $G<256)            $G=$G-60;
        if ($B>60 and $B<256)            $B=$B-60;
        $CurrentDarkColor=imagecolorallocate($image,$R,$G,$B);
        //画扇形弧
        imagearc($image,$PieCenterX,$PieCenterY,$DoubleA,$DoubleB,$StartDegrees,$EndDegrees,$CurrentColor);
        //画直线
        list($ArcX, $ArcY) = pie_point($StartDegrees , $this->a , $this->b);
        imageline($image,$PieCenterX,$PieCenterY,floor($PieCenterX + $ArcX),floor($PieCenterY + $ArcY),$CurrentColor);
        //画直线
        list($ArcX, $ArcY) = pie_point($EndDegrees,$this->a , $this->b);
        imageline($image,$PieCenterX,$PieCenterY,ceil($PieCenterX + $ArcX),ceil($PieCenterY + $ArcY),$CurrentColor);
        //填充扇形
        $MidPoint = round((($EndDegrees - $StartDegrees)/2) + $StartDegrees);
        list($ArcX, $ArcY) = Pie_point($MidPoint, $this->a*3/4 , $this->b*3/4);
        
        imagefilltoborder($image,floor($PieCenterX + $ArcX),floor($PieCenterY + $ArcY), $CurrentColor,$CurrentColor);
        imagestring($image,2,floor($PieCenterX + $ArcX-5),floor($PieCenterY + $ArcY-5),$percent."%",$colorBorder);

        //画阴影
        if ($StartDegrees>=0 and $StartDegrees<=180){
           if($EndDegrees<=180){    
               for($k = 1; $k < 15; $k++)
                imagearc($image,$PieCenterX, $PieCenterY+$k,$DoubleA, $DoubleB, $StartDegrees, $EndDegrees, $CurrentDarkColor);
           }else{
               for($k = 1; $k < 15; $k++)
                imagearc($image,$PieCenterX, $PieCenterY+$k,$DoubleA, $DoubleB, $StartDegrees, 180, $CurrentDarkColor);
           }

        }
   }
        
    /*到此脚本已经生了一幅图像了
    **现在需要的是把它发到浏览器上,重要的一点是要将标头发给浏览器,让它知道是一个GIF文件。不然的话你只能看到一堆奇怪的乱码
    */ 
    //输出生成的图片    
    header("Content-type: image/gif");
    imagegif($image);
    imagedestroy($image);
}//End drawPie()
}//End class


//实现

$objp = new chart();
$objp->DrawPie();
?> 

<?php
require_once("../dbconnect.php");
$proimagepath="photo/";
$product_id=$_POST["product_id"];
$product_pid=$_POST["product_pid"];
$product_title=$_POST["product_title"];
$product_name=$_POST["product_name"];
$product_xinghao=$_POST["product_xinghao"];
$product_yongtu=$_POST["product_yongtu"];
$product_danjia=$_POST["product_danjia"];
$product_content=mysql_escape_string($_POST["content1"]);
$product_date=date("YmdHis");
$product_smallid=$_POST["product_catename"];
$product_img=$_FILES["smallimage"];
$smalltype=$product_img["type"];
////数据验证////////////////
if($product_name=="")
{
    alert_back("产品名称不能为空!");
exit;
}
if(!$smalltype=getImgType($smalltype))
{
   alert_back("上传的图片类型不对!");
   exit;
}
///////////上传图片/////////////////
$smallimgname=$product_smallid.$product_date.".".$smalltype;
$smallimgpath=$proimagepath.$smallimgname;
if(!move_uploaded_file($product_img["tmp_name"],"../".$smallimgpath))
{
    alert_back("上传图片失败!");
exit;
}

//////////添加数据到数据库///////////////
$insertSQL="insert into product (product_title,product_name,product_xinghao,product_yongtu,product_danjia,product_img,product_content,product_date,product_smallid,product_pid) values
('$product_title','$product_name','$product_xinghao','$product_yongtu','$product_danjia','$smallimgpath','$product_content','$product_date','$product_smallid','$product_pid')";
mysql_query("SET NAMES 'gb2312'");
//echo($insertSQL);
if(mysql_query($insertSQL))
{
    alert_back("添加产品成功!");
}
else
{
    alert_back("添加产品失败!");
}
?>


在网上找的水印代码:
/*
* 功能:PHP图片水印 (水印支持图片或文字)
* 参数:
*      $product_img    背景图片,即需要加水印的图片,暂只支持GIF,JPG,PNG格式;
*      $waterPos        水印位置,有10种状态,0为随机位置;
*                        1为顶端居左,2为顶端居中,3为顶端居右;
*                        4为中部居左,5为中部居中,6为中部居右;
*                        7为底端居左,8为底端居中,9为底端居右;
*      $waterImage        图片水印,即作为水印的图片,暂只支持GIF,JPG,PNG格式;
*      $waterText        文字水印,即把文字作为为水印,支持ASCII码,不支持中文;
*      $textFont        文字大小,值为1、2、3、4或5,默认为5;
*      $textColor        文字颜色,值为十六进制颜色值,默认为#FF0000(红色);
*
* 注意:Support GD 2.0,Support FreeType、GIF Read、GIF Create、JPG 、PNG
*      $waterImage 和 $waterText 最好不要同时使用,选其中之一即可,优先使用 $waterImage。
*      当$waterImage有效时,参数$waterString、$stringFont、$stringColor均不生效。
*      加水印后的图片的文件名和 $product_img 一样。
* 作者:longware @ 2004-11-3 14:15:13
*/
function imageWaterMark($product_img,$waterPos=0,$waterImage="",$waterText="",$textFont=5,$textColor="#FF0000")
{
    $isWaterImage = FALSE;
    $formatMsg = "暂不支持该文件格式,请用图片处理软件将图片转换为GIF、JPG、PNG格式。";
    //读取水印文件
    if(!empty($waterImage) && file_exists($waterImage))
    {
        $isWaterImage = TRUE;
        $water_info = getimagesize($waterImage);
        $water_w    = $water_info[0];//取得水印图片的宽
        $water_h    = $water_info[1];//取得水印图片的高
        switch($water_info[2])//取得水印图片的格式
        {
            case 1water_im = imagecreatefromgif($waterImage);break;
            case 2water_im = imagecreatefromjpeg($waterImage);break;
            case 3water_im = imagecreatefrompng($waterImage);break;
            default:die($formatMsg);
        }
    }
    //读取背景图片
    if(!empty($product_img) && file_exists($product_img))
    {
        $ground_info = getimagesize($product_img);
        $ground_w    = $ground_info[0];//取得背景图片的宽
        $ground_h    = $ground_info[1];//取得背景图片的高
        switch($ground_info[2])//取得背景图片的格式
        {
            case 1:$ground_im = imagecreatefromgif($product_img);break;
            case 2:$ground_im = imagecreatefromjpeg($product_img);break;
            case 3:$ground_im = imagecreatefrompng($product_img);break;
            default:die($formatMsg);
        }
    }
    else
    {
        die("需要加水印的图片不存在!");
    }
    //水印位置
    if($isWaterImage)//图片水印
    {
        $w = $water_w;
        $h = $water_h;
        $label = "图片的";
    }
    else//文字水印
    {
        $temp = imagettfbbox(ceil($textFont*2.5),0,"arial.ttf",$waterText);//取得使用 TrueType 字体的文本的范围
        $w = $temp[2] - $temp[6];
        $h = $temp[3] - $temp[7];
        unset($temp);
        $label = "文字区域";
    }
    if( ($ground_w<$w) || ($ground_h<$h) )
    {
        echo "需要加水印的图片的长度或宽度比水印".$label."还小,无法生成水印!";
        return;
    }
    switch($waterPos)
    {
        case 0://随机
            $posX = rand(0,($ground_w - $w));
            $posY = rand(0,($ground_h - $h));
            break;
        case 1://1为顶端居左
            $posX = 0;
            $posY = 0;
            break;
        case 2://2为顶端居中
            $posX = ($ground_w - $w) / 2;
            $posY = 0;
            break;
        case 3://3为顶端居右
            $posX = $ground_w - $w;
            $posY = 0;
            break;
        case 4://4为中部居左
            $posX = 0;
            $posY = ($ground_h - $h) / 2;
            break;
        case 5://5为中部居中
            $posX = ($ground_w - $w) / 2;
            $posY = ($ground_h - $h) / 2;
            break;
        case 6://6为中部居右
            $posX = $ground_w - $w;
            $posY = ($ground_h - $h) / 2;
            break;
        case 7://7为底端居左
            $posX = 0;
            $posY = $ground_h - $h;
            break;
        case 8://8为底端居中
            $posX = ($ground_w - $w) / 2;
            $posY = $ground_h - $h;
            break;
        case 9://9为底端居右
            $posX = $ground_w - $w;
            $posY = $ground_h - $h;
            break;
        default://随机
            $posX = rand(0,($ground_w - $w));
            $posY = rand(0,($ground_h - $h));
            break;     
    }
    //设定图像的混色模式
    imagealphablending($ground_im, true);
    if($isWaterImage)//图片水印
    {
        imagecopy($ground_im, $water_im, $posX, $posY, 0, 0, $water_w,$water_h);//拷贝水印到目标文件         
    }
    else//文字水印
    {
        if( !empty($textColor) && (strlen($textColor)==7) )
        {
            $R = hexdec(substr($textColor,1,2));
            $G = hexdec(substr($textColor,3,2));
            $B = hexdec(substr($textColor,5));
        }
        else
        {
            die("水印文字颜色格式不正确!");
        }
        imagestring ( $ground_im, $textFont, $posX, $posY, $waterText, imagecolorallocate($ground_im, $R, $G, $B));         
    }
    //生成水印后的图片
    @unlink($product_img);
    switch($ground_info[2])//取得背景图片的格式
    {
        case 1:imagegif($ground_im,$product_img);break;
        case 2:imagejpeg($ground_im,$product_img);break;
        case 3:imagepng($ground_im,$product_img);break;
        default:die($errorMsg);
    }
    //释放内存
    if(isset($water_info)) unset($water_info);
    if(isset($water_im)) imagedestroy($water_im);
    unset($ground_info);
    imagedestroy($ground_im);
}

//---------------------------------------------------------------------------------------
if(isset($_FILES) && !empty($_FILES['userfile']) && $_FILES['userfile']['size']>0)
{
    $uploadfile = "./".time()."_".$_FILES['userfile']['name'];
    if (copy($_FILES['userfile']['tmp_name'], $uploadfile))
    {
        echo "OK<br>";
        //文字水印
        imageWaterMark($uploadfile,0,"","http://www.hi-pwr.com",5,"#FF0000");
        //图片水印
        //$waterImage="images/bz.gif";//水印图片路径
        //imageWaterMark($uploadfile,0,$waterImage);
        echo "<img src="".$uploadfile."" border="0">";
    }
    else
    {
        echo "Fail<br>";
    }
}

ob_start();
$start = microtime(true);
$src = imagecreatefromjpeg($_GET["imageurl"]);
$width = imagesx($src);
$height = imagesy($src);
$dst = imagecreatetruecolor(160, 120);
imagecopyresampled($dst,$src,0,0,0,0,160,120,$width,$height);
header('Content-Type: image/jpeg');
imagejpeg($dst,'',100);
ob_end_clean();
echo microtime(true) - $start;

图片生成缩略图代码

<?php
# Constants
define("IMAGE_BASE", './');
define("MAX_WIDTH", 150);
define("MAX_HEIGHT", 150);

# Get image locationstr_replace('..', '', $_SERVER['QUERY_STRING']);
$image_file = 't.jpg';
$image_path = IMAGE_BASE . "$image_file";

# Load image
$img = null;
$ext = strtolower(end(explode('.', $image_path)));
if ($ext == 'jpg' || $ext == 'jpeg') {
     $img = imagecreatefromjpeg($image_path);
} else if ($ext == 'png') {
     $img = @imagecreatefrompng($image_path);
# Only if your version of GD includes GIF support
} else if ($ext == 'gif') {
     $img = @imagecreatefrompng($image_path);
}

# If an image was successfully loaded, test the image for size
if ($img) {

     # Get image size and scale ratio
     $width = imagesx($img);
     $height = imagesy($img);
     $scale = min(MAX_WIDTH/$width, MAX_HEIGHT/$height);

     # If the image is larger than the max shrink it
     if ($scale < 1) {
         $new_width =150; //floor($scale*$width);
         $new_height =150;// floor($scale*$height);

         # Create a new temporary image
         $tmp_img = imagecreatetruecolor($new_width, $new_height);

         # Copy and resize old image into new image
         imagecopyresized($tmp_img, $img, 0, 0, 0, 0,$new_width, $new_height, $width, $height);
         imagedestroy($img);
         $img = $tmp_img;
     }
}

# Create error image if necessary
if (!$img) {
     $img = imagecreate(MAX_WIDTH, MAX_HEIGHT);
     imagecolorallocate($img,0,0,0);
     $c = imagecolorallocate($img,70,70,70 );
     imageline($img,0,0,MAX_WIDTH,MAX_HEIGHT,$c2);
     imageline($img,MAX_WIDTH,0,0,MAX_HEIGHT,$c2);
}

# Display the image
header("Content-type: image/jpeg");
imagejpeg($img);
imagedestroy($img);
?>

[!--infotagslink--]

相关文章

  • 使用PHP+JavaScript将HTML页面转换为图片的实例分享

    这篇文章主要介绍了使用PHP+JavaScript将HTML元素转换为图片的实例分享,文后结果的截图只能体现出替换的字体,也不能说将静态页面转为图片可以加快加载,只是这种做法比较interesting XD需要的朋友可以参考下...2016-04-19
  • php抓取网站图片并保存的实现方法

    php如何实现抓取网页图片,相较于手动的粘贴复制,使用小程序要方便快捷多了,喜欢编程的人总会喜欢制作一些简单有用的小软件,最近就参考了网上一个php抓取图片代码,封装了一个php远程抓取图片的类,测试了一下,效果还不错分享...2015-10-30
  • C#从数据库读取图片并保存的两种方法

    这篇文章主要介绍了C#从数据库读取图片并保存的方法,帮助大家更好的理解和使用c#,感兴趣的朋友可以了解下...2021-01-16
  • Photoshop古装美女图片转为工笔画效果制作教程

    今天小编在这里就来给各位Photoshop的这一款软件的使用者们来说说把古装美女图片转为细腻的工笔画效果的制作教程,各位想知道方法的使用者们,那么下面就快来跟着小编一...2016-09-14
  • Python 图片转数组,二进制互转操作

    这篇文章主要介绍了Python 图片转数组,二进制互转操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-03-09
  • 利用JS实现点击按钮后图片自动切换的简单方法

    下面小编就为大家带来一篇利用JS实现点击按钮后图片自动切换的简单方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2016-10-25
  • jquery左右滚动焦点图banner图片鼠标经过显示上下页按钮

    jquery左右滚动焦点图banner图片鼠标经过显示上下页按钮...2013-10-13
  • js实现上传图片及时预览

    这篇文章主要为大家详细介绍了js实现上传图片及时预览的相关资料,具有一定的参考价值,感兴趣的朋友可以参考一下...2016-05-09
  • Photoshop枪战电影海报图片制作教程

    Photoshop的这一款软件小编相信很多的人都已经是使用过了吧,那么今天小编在这里就给大家带来了用Photoshop软件制作枪战电影海报的教程,想知道制作步骤的玩家们,那么下面...2016-09-14
  • php二维码生成

    本文介绍两种使用 php 生成二维码的方法。 (1)利用google生成二维码的开放接口,代码如下: /** * google api 二维码生成【QRcode可以存储最多4296个字母数字类型的任意文本,具体可以查看二维码数据格式】 * @param strin...2015-10-21
  • Java生成随机姓名、性别和年龄的实现示例

    这篇文章主要介绍了Java生成随机姓名、性别和年龄的实现示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-10-01
  • python opencv通过4坐标剪裁图片

    图片剪裁是常用的方法,那么如何通过4坐标剪裁图片,本文就详细的来介绍一下,感兴趣的小伙伴们可以参考一下...2021-06-04
  • C#生成随机数功能示例

    这篇文章主要介绍了C#生成随机数功能,涉及C#数学运算与字符串操作相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下...2020-06-25
  • 使用PHP下载CSS文件中的图片的代码

    共享一段使用PHP下载CSS文件中的图片的代码 复制代码 代码如下: <?php //note 设置PHP超时时间 set_time_limit(0); //note 取得样式文件内容 $styleFileContent = file_get_contents('images/style.css'); //not...2013-10-04
  • 微信小程序如何获取图片宽度与高度

    这篇文章主要给大家介绍了关于微信小程序如何获取图片宽度与高度的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-03-10
  • php生成唯一数字id的方法汇总

    关于生成唯一数字ID的问题,是不是需要使用rand生成一个随机数,然后去数据库查询是否有这个数呢?感觉这样的话有点费时间,有没有其他方法呢?当然不是,其实有两种方法可以解决。 1. 如果你只用php而不用数据库的话,那时间戳+随...2015-11-24
  • PHP swfupload图片上传的实例代码

    PHP代码如下:复制代码 代码如下:if (isset($_FILES["Filedata"]) || !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) || $_FILES["Filedata"]["error"] != 0) { $upload_file = $_FILES['Filedata']; $fil...2013-10-04
  • ps怎么制作图片阴影效果

    ps软件是现在很多人比较喜欢的,有着非常不错的使用效果,这次文章就给大家介绍下ps怎么制作图片阴影效果,还不知道制作方法的赶紧来看看。 ps图片阴影效果怎么做方法/...2017-07-06
  • C#中图片旋转和翻转(RotateFlipType)用法分析

    这篇文章主要介绍了C#中图片旋转和翻转(RotateFlipType)用法,实例分析了C#图片旋转及翻转Image.RotateFlip方法属性的常用设置技巧,需要的朋友可以参考下...2020-06-25
  • OpenCV如何去除图片中的阴影的实现

    这篇文章主要介绍了OpenCV如何去除图片中的阴影的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-03-29