aidan Mon Oct 4 05:45:47 2004 EDT
Modified files:
/phpdoc/en/reference/image/functions imagecopyresized.xml
Log:
Added examples
http://cvs.php.net/diff.php/phpdoc/en/reference/image/functions/imagecopyresized.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/image/functions/imagecopyresized.xml
diff -u phpdoc/en/reference/image/functions/imagecopyresized.xml:1.3
phpdoc/en/reference/image/functions/imagecopyresized.xml:1.4
--- phpdoc/en/reference/image/functions/imagecopyresized.xml:1.3 Sat Jan 18
22:09:48 2003
+++ phpdoc/en/reference/image/functions/imagecopyresized.xml Mon Oct 4 05:45:45
2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/image.xml, last change in rev 1.36 -->
<refentry id="function.imagecopyresized">
<refnamediv>
@@ -8,30 +8,30 @@
</refnamediv>
<refsect1>
<title>Description</title>
- <methodsynopsis>
- <type>int</type><methodname>imagecopyresized</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>
- </methodsynopsis>
+ <methodsynopsis>
+ <type>int</type><methodname>imagecopyresized</methodname>
+ <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>imagecopyresized</function> copies a rectangular
portion of one image to another image.
- <parameter>Dst_im</parameter> is the destination image,
- <parameter>src_im</parameter> is the source image identifier. If
- the source and destination coordinates and width and heights
+ <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
- 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
+ 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_image</parameter> is the same as
+ <parameter>src_image</parameter>) but if the regions overlap the
results will be unpredictable.
</para>
<note>
@@ -47,8 +47,55 @@
<function>imagecreatetruecolor</function>.
</para>
</note>
+ </refsect1>
+
+ <refsect1>
+ &reftitle.examples;
+ <para>
+ <example>
+ <title>Resizing an image</title>
+ <para>
+ This example will display the image at half size.
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?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 = imagecreate($newwidth, $newheight);
+$source = imagecreatefromjpeg($filename);
+
+// Resize
+imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
+
+// Output
+imagejpeg($thumb);
+?>
+]]>
+ </programlisting>
+ <para>
+ The image will be output at half size, though better
+ quality could be obtained using <function>imagecopyresampled</function>.
+ </para>
+ </example>
+ </para>
+ </refsect1>
+
+ <refsect1>
+ &reftitle.seealso;
<para>
- See also <function>imagecopyresampled</function>.
+ <function>imagecopyresampled</function>
</para>
</refsect1>
</refentry>