放大
一:
我有原圖
oldimg.PNG
現在要用php對其放小10%或放大200%怎麼寫代碼啊
二:
我有原圖
oldimg.PNG
高為200,寬為300
我要在上面剪下
座標為
10,10,50,30
X,Y,W,H
用php代碼怎麼在原圖上剪下,生存新的圖片啊
1、
<?php
$image = "oldimg.PNG"; // 原圖
$imgstream = file_get_contents($image);
$im = imagecreatefromstring($imgstream);
$x = imagesx($im);
$y = imagesy($im);
//放大200%,縮小雷同
$thumbw = $x*2; // 期望的靶心圖表寬
$thumbh = $y*2; // 期望的靶心圖表高
if(function_exists("imagecreatetruecolor"))
$dim = imagecreatetruecolor($thumbw, $thumbh); // 建立靶心圖表gd2
else
$dim = imagecreate($thumbw, $thumbh); // 建立靶心圖表gd1
imagecopyresized ($dim,$im,0,0,0,0,$thumbw,$thumbh,$x,$y);
header ("Content-type: image/jpeg");
imagejpeg ($dim);
?>
2、
<?php
$image = "oldimg.PNG"; // 原圖
$imgstream = file_get_contents($image);
$im = imagecreatefromstring($imgstream);
$x = imagesx($im);
$y = imagesy($im);
$thumbw = 50; // 期望的靶心圖表寬
$thumbh = 30; // 期望的靶心圖表高
if(function_exists("imagecreatetruecolor"))
$dim = imagecreatetruecolor($thumbw, $thumbh); // 建立靶心圖表gd2
else
$dim = imagecreate($thumbw, $thumbh); // 建立靶心圖表gd1
imagecopyresized ($dim,$im,0,0,10,10,$thumbw,$thumbh,$thumbw,$thumbh);
header ("Content-type: image/jpeg");
imagejpeg ($dim);
?>