cvs: phpdoc /en/reference/image/functions imagecopyresampled.xml

From: Date: Mon, 04 Oct 2004 09:50:19 +0000
Subject: cvs: phpdoc /en/reference/image/functions imagecopyresampled.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969364410@lists.php.net to get a copy of this message
aidan Mon Oct 4 05:50:19 2004 EDT Modified files: /phpdoc/en/reference/image/functions imagecopyresampled.xml Log: Added examples http://cvs.php.net/diff.php/phpdoc/en/reference/image/functions/imagecopyresampled.xml?r1=1.5&r2=1.6&ty=u Index: phpdoc/en/reference/image/functions/imagecopyresampled.xml diff -u phpdoc/en/reference/image/functions/imagecopyresampled.xml:1.5 phpdoc/en/reference/image/functions/imagecopyresampled.xml:1.6 --- phpdoc/en/reference/image/functions/imagecopyresampled.xml:1.5 Fri Jun 11 04:25:38 2004 +++ phpdoc/en/reference/image/functions/imagecopyresampled.xml Mon Oct 4 05:50:18 2004 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <!-- splitted from ./en/functions/image.xml, last change in rev 1.36 --> <refentry id="function.imagecopyresampled"> <refnamediv> @@ -10,30 +10,33 @@ <title>Description</title> <methodsynopsis> <type>bool</type><methodname>imagecopyresampled</methodname> - <methodparam><type>resource</type><parameter>dst_im</parameter></methodparam> - <methodparam><type>resource</type><parameter>src_im</parameter></methodparam> - <methodparam><type>int</type><parameter>dstX</parameter></methodparam> - <methodparam><type>int</type><parameter>dstY</parameter></methodparam> - <methodparam><type>int</type><parameter>srcX</parameter></methodparam> - <methodparam><type>int</type><parameter>srcY</parameter></methodparam> - <methodparam><type>int</type><parameter>dstW</parameter></methodparam> - <methodparam><type>int</type><parameter>dstH</parameter></methodparam> - <methodparam><type>int</type><parameter>srcW</parameter></methodparam> - <methodparam><type>int</type><parameter>srcH</parameter></methodparam> + <methodparam><type>resource</type><parameter>dst_image</parameter></methodparam> + <methodparam><type>resource</type><parameter>src_image</parameter></methodparam> + <methodparam><type>int</type><parameter>dst_x</parameter></methodparam> + <methodparam><type>int</type><parameter>dst_y</parameter></methodparam> + <methodparam><type>int</type><parameter>src_x</parameter></methodparam> + <methodparam><type>int</type><parameter>src_y</parameter></methodparam> + <methodparam><type>int</type><parameter>dst_w</parameter></methodparam> + <methodparam><type>int</type><parameter>dst_h</parameter></methodparam> + <methodparam><type>int</type><parameter>src_w</parameter></methodparam> + <methodparam><type>int</type><parameter>src_h</parameter></methodparam> </methodsynopsis> <para> <function>imagecopyresampled</function> copies a rectangular portion of one image to another image, smoothly interpolating pixel values so that, in particular, reducing the size of an image still - retains a great deal of clarity. &return.success; - <parameter>dst_im</parameter> is the destination image, - <parameter>src_im</parameter> is the source image identifier. If + retains a great deal of clarity. + &return.success; + </para> + <para> + <parameter>dst_image</parameter> is the destination image, + <parameter>src_image</parameter> 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 + will be performed. The coordinates refer to the upper left corner. This function can be used to copy regions within the - same image (if <parameter>dst_im</parameter> is the same as - <parameter>src_im</parameter>) but if the regions overlap the + same image (if <parameter>dst_image</parameter> is the same as + <parameter>src_image</parameter>) but if the regions overlap the results will be unpredictable. </para> <note> @@ -50,8 +53,92 @@ </para> </note> &note.gd.2; + </refsect1> + + <refsect1> + &reftitle.examples; + + <para> + <example> + <title>Simple example</title> + <para> + This example will resample an image to half its original size. + </para> + <programlisting role="php"> +<![CDATA[ +<?php +// The file +$filename = 'test.jpg'; +$percent = 0.5; + +// Content type +header('Content-type: image/jpeg'); + +// Get new dimensions +list($width, $height) = getimagesize($filename); +$new_width = $width * $percent; +$new_height = $height * $percent; + +// Resample +$image_p = imagecreatetruecolor($new_width, $new_height); +$image = imagecreatefromjpeg($filename); +imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); + +// Output +imagejpeg($image_p, null, 100); +?> +]]> + </programlisting> + </example> + </para> + + <para> + <example> + <title>Resampling an image proportionally</title> + <para> + This example will display an image with the maximum width, + or height, of 200 pixels. + </para> + <programlisting role="php"> +<![CDATA[ +<?php +// The file +$filename = 'test.jpg'; + +// Set a maximum height and width +$width = 200; +$height = 200; + +// Content type +header('Content-type: image/jpeg'); + +// Get new dimensions +list($width_orig, $height_orig) = getimagesize($filename); + +if ($width && ($width_orig < $height_orig)) { + $width = ($height / $height_orig) * $width_orig; +} else { + $height = ($width / $width_orig) * $height_orig; +} + +// Resample +$image_p = imagecreatetruecolor($width, $height); +$image = imagecreatefromjpeg($filename); +imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); + +// Output +imagejpeg($image_p, null, 100); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + + <refsect1> + &reftitle.seealso; <para> - See also <function>imagecopyresized</function>. + <function>imagecopyresized</function> </para> </refsect1> </refentry>

« previous php.doc (#969364410) next »