本人想截取一类图片的一个区域
在网上也找过几个图片处理的类
但是都不好用
特此 求得一个截取文件
原来自己写的文件 总是在 imagecreatefromjpeg 后 报内存错误
在网上也找过几个图片处理的类
但是都不好用
特此 求得一个截取文件
原来自己写的文件 总是在 imagecreatefromjpeg 后 报内存错误
解决方案 »
- 虚拟机的PHP连接MYSQL错误
- 这个php文件和图片我放在同一目录在,还提示没有这个文件,郁闷啊。
- session变量不能自动失效吗
- 求一段时间内每天的最大值怎么做?
- 高分求教,在线等.windows下面用php自带的zipArchive压缩成功,用winrar解压出CRC错误.
- 帮我看看这个错误是什么意思?apache 的log.txt文件中的。数据库是mysql
- 连接mysql问题
- 请教前辈有关php echo输出问题
- 如何搭建mail服务器提供mail服务,如何使用二级域名,如解决22点结贴
- 为什么我的php中使用了session变量,但如果进入其他目录时如,www.a.com/bbs,一进入
- 单引号转义符“\'”为什么我输入之后总是提示错误
- this和self
imagecopyresized() copies a rectangular portion of one image to another image. dst_image is the destination image, src_image is the source image identifier.In other words, imagecopyresized() will take an rectangular area from src_image of width src_w and height src_h at position (src_x,src_y) and place it in a rectangular area of dst_image of width dst_w and height dst_h at position (dst_x,dst_y).If the source and destination coordinates and width and heights differ, appropriate stretching or shrinking of the image fragment will be performed. The coordinates refer to the upper left corner. This function can be used to copy regions within the same image (if dst_image is the same as src_image) but if the regions overlap the results will be unpredictable.<?php
// File and new size
$filename = 'test.jpg';
$percent = 0.5;// Content type
header('Content-Type: image/jpeg');// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);// Output
imagejpeg($thumb);
?>
$s = file_get_contents($url);
$ims = imagecreatefromstring($s);$w = imagesx($ims);
$h = imagesy($ims);$imd = imagecreatetruecolor($w/2, $h/2);
imagecopy($imd, $ims, 0, 0, $w/4, $h/4, $w/2, $h/2);
imagepng($imd);