(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).
���Դ��Ŀ��Ŀ�Ⱥ߶Ȳ�ͬ����������Ӧ��ͼ�����������졣����ָ�������Ͻǡ���������������ͬһ��ͼ�ڲ����������
dst_image �� src_image
��ͬ�Ļ���������������Ļ���������Ԥ֪��
dst_imageĿ��ͼ��������Դ��
src_imageԴͼ��������Դ��
dst_xx-coordinate of destination point.
dst_yy-coordinate of destination point.
src_xx-coordinate of source point.
src_yy-coordinate of source point.
dst_wDestination width.
dst_hDestination height.
src_wԴͼ��Ŀ�ȡ�
src_hԴͼ��ĸ߶ȡ�
�ɹ�ʱ���� TRUE�� ������ʧ��ʱ���� FALSE��
Example #1 Resizing an image
������ӻ���һ��ijߴ���ʾͼƬ
<?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:
��Ϊ��ɫ��ͼ�����ƣ�255+1 ����ɫ���и����⡣�ز��������ͼ��ͨ����Ҫ���� 255 ����ɫ�������µı��ز��������ؼ�����ɫʱ������һ�ֽ���ֵ���Ե�ɫ��ͼ���Է���һ������ɫʱ�����ʧ������ѡ���˼�������ӽ��������ϣ�����ɫ���Ⲣ�������Ӿ�����ӽ�����ɫ������ܻ��������Ľ��������հף������Ӿ����ǿհף���ͼ��Ҫ����������⣬��ʹ�����ɫͼ����ΪĿ��ͼ�������� imagecreatetruecolor() �����ġ�
imagecopyresampled() - �ز�����������ͼ������С