(PHP 4, PHP 5, PHP 7)
imagecopyresized — 锟斤拷锟斤拷锟斤拷锟斤拷图锟今并碉拷锟斤拷锟斤拷小
$dst_image
, resource $src_image
, int $dst_x
, int $dst_y
, int $src_x
, int $src_y
, int $dst_w
, int $dst_h
, int $src_w
, int $src_h
) : bool
imagecopyresized()
锟斤拷一锟斤拷图锟斤拷锟叫碉拷一锟斤拷锟斤拷锟斤拷锟斤拷蚩奖锟斤拷锟斤拷锟揭伙拷锟酵硷拷锟斤拷小锟�dst_image
锟斤拷 src_image
锟街憋拷锟斤拷目锟斤拷图锟斤拷锟皆赐硷拷锟侥憋拷识锟斤拷锟斤拷
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
).
锟斤拷锟皆达拷锟侥匡拷锟侥匡拷群透叨炔锟酵拷锟斤拷锟斤拷锟斤拷锟斤拷锟接︼拷锟酵硷拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷臁o拷锟斤拷锟街革拷锟斤拷锟斤拷锟斤拷辖恰锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟酵伙拷锟酵硷拷诓锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷
dst_image
锟斤拷 src_image
锟斤拷同锟侥伙拷锟斤拷锟斤拷锟津,碉拷锟斤拷锟斤拷锟斤拷蚪坏锟斤拷幕锟斤拷锟斤拷锟斤拷锟斤拷锟皆ぶ拷锟�
dst_image
目锟斤拷图锟斤拷锟斤拷锟斤拷锟斤拷源锟斤拷
src_image
源图锟斤拷锟斤拷锟斤拷锟斤拷源锟斤拷
dst_x
x-coordinate of destination point.
dst_y
y-coordinate of destination point.
src_x
x-coordinate of source point.
src_y
y-coordinate of source point.
dst_w
Destination width.
dst_h
Destination height.
src_w
源图锟斤拷目锟饺★拷
src_h
源图锟斤拷母叨取锟�
锟缴癸拷时锟斤拷锟斤拷 TRUE
锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE
锟斤拷
Example #1 Resizing an image
锟斤拷锟斤拷锟斤拷踊锟斤拷锟揭伙拷锟侥尺达拷锟斤拷示图片
<?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);
?>
锟斤拷锟斤拷锟斤拷锟教碉拷锟斤拷锟斤拷锟斤拷锟斤拷冢锟�
The image will be output at half size, though better quality could be obtained using imagecopyresampled().
Note:
锟斤拷为锟斤拷色锟斤拷图锟斤拷锟斤拷锟狡o拷255+1 锟斤拷锟斤拷色锟斤拷锟叫革拷锟斤拷锟解。锟截诧拷锟斤拷锟斤拷锟斤拷锟酵硷拷锟酵拷锟斤拷锟揭拷锟斤拷锟� 255 锟斤拷锟斤拷色锟斤拷锟斤拷锟斤拷锟铰的憋拷锟截诧拷锟斤拷锟斤拷锟斤拷锟截硷拷锟斤拷锟斤拷色时锟斤拷锟斤拷锟斤拷一锟街斤拷锟斤拷值锟斤拷锟皆碉拷色锟斤拷图锟斤拷锟皆凤拷锟斤拷一锟斤拷锟斤拷锟斤拷色时锟斤拷锟斤拷锟绞э拷锟斤拷锟斤拷锟窖★拷锟斤拷思锟斤拷锟斤拷锟斤拷锟接斤拷锟斤拷锟斤拷锟斤拷锟较o拷锟斤拷锟斤拷色锟斤拷锟解并锟斤拷锟斤拷锟斤拷锟接撅拷锟斤拷锟斤拷咏锟斤拷锟斤拷锟缴拷锟斤拷锟斤拷锟杰伙拷锟斤拷锟斤拷锟斤拷锟侥斤拷锟斤拷锟斤拷锟斤拷锟秸白o拷锟斤拷锟斤拷锟接撅拷锟斤拷锟角空白o拷锟斤拷图锟斤拷要锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷猓拷锟绞癸拷锟斤拷锟斤拷色图锟斤拷锟斤拷为目锟斤拷图锟斤拷锟斤拷锟斤拷锟斤拷 imagecreatetruecolor() 锟斤拷锟斤拷锟侥★拷
imagecopyresampled() - 锟截诧拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷图锟今并碉拷锟斤拷锟斤拷小