★ wanayoo — archive 1999 http://www.php.net/manual/function.imagecopyresized.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Graphics
Quick Reference
German version of this pageJapanese version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
Graphics
* GetImageSize
* ImageArc
* ImageChar
* ImageCharUp
* ImageColorAllocate
* ImageColorDeAllocate
* ImageColorAt
* ImageColorClosest
* ImageColorExact
* ImageColorResolve
* ImageGammaCorrect
* ImageColorSet
* ImageColorsForIndex
* ImageColorsTotal
* ImageColorTransparent
* ImageCopy
* ImageCopyResized
* ImageCreate
* ImageCreateFromGIF
* ImageCreateFromJPEG
* ImageCreateFromPNG
* ImageDashedLine
* ImageDestroy
* ImageFill
* ImageFilledPolygon
* ImageFilledRectangle
* ImageFillToBorder
* ImageFontHeight
* ImageFontWidth
* ImageGIF
* ImagePNG
* ImageJPEG
* ImageInterlace
* ImageLine
* ImageLoadFont
* ImagePolygon
* ImagePSBBox
* ImagePSEncodeFont
* ImagePSFreeFont
* ImagePSLoadFont
* ImagePsExtendFont
* ImagePsSlantFont
* ImagePSText
* ImageRectangle
* ImageSetPixel
* ImageString
* ImageStringUp
* ImageSX
* ImageSY
* ImageTTFBBox
* ImageTTFText
* ImageTypes
* read_exif_data
Manual: ImageCopyResized
View the source code for this pageSearch the site



Previous page
 ImageCopy
 Updated
Sat, 12 Aug 2000
ImageCreate 
Next page


ImageCopyResized

(unknown)

ImageCopyResized -- Copy and resize part of an image

Description

int imagecopyresized (int dst_im, int src_im, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH)

ImageCopyResized() copies a rectangular portion of one image to another image. Dst_im is the destination image, src_im is the source image identifier. 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_im is the same as src_im) but if the regions overlap the results will be unpredictable.


User Contributed Notes: ImageCopyResized


thamers@scheltema.nl
16-Sep-1999 07:15
Could anyone supply some sample code for this function ?


plusplus7@hotmail.com
25-Sep-1999 03:10
saw this one on the ng and it works fine - just trying to figure it out for jpg.

<?

$new_w=100;

$new_h=100;



header("Content-type: image/gif");



$dst_img=ImageCreate($new_w,$new_h);

$src_img=ImageCreateFromGif("./imgtest.gif");



ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),ImageSY($src_img));

ImageGif($dst_img);

?>



gregg@world.net
17-Oct-1999 07:27
A useful GD function which is not included in this documentation is ImageCopy. It is very similiar to imagecopyresized but it doesn't do anything to the copied image

int imagecopyresized(int dst_im, int src_im, int dstX, int dstY, int dstW, int dstH, int srcW, int srcH);



bolke@xs4all.nl
02-Dec-1999 05:49
So, ok I understand how to do this on GIF's. But now, how to do it on PNG/JPG etc? Maybe even from a database?


jeff@zaius.org
05-Jul-2000 06:34
To do the same with a JPEG, you must have PHP 3.0.16+ installed, and GD 1.8+. Here is a sample

<pre>
$src_img = imagecreatefromjpeg($imagefile);
$new_w = imagesx($src_img)/4;
$new_h = imagesy($src_img)/4;
$dst_img = imagecreate($new_w,$new_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));
imagejpeg($dst_img, "scratch/$imagefile");
echo "<img src=/old?u=http%3A%2F%2Fwww.php.net%2Fmanual%2Fscratch%2F%24imagefile%26gt%3B%5Cn%26quot%3B%3B&y=1999
</pre>



hoiarie@hotmail.com
15-Jul-2000 04:57
If you want to resize or copy an image from or to a datbase, just use a temp-file as buffer. E.g.: copy all the image-data from the database to a tempfile, use the resize-function on another tempfile and copy all the data from to tempfile back into the database.


 About Notes


Previous page
 ImageCopy
 Updated
Sat, 12 Aug 2000
ImageCreate 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.