reference/image/functions/imagecrop.xml
593ea510e853ff034e03f78a4be0daa41661c9d4
...
...
@@ -1,25 +1,23 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-

4
3
<refentry xml:id="function.imagecrop" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
4
<refnamediv>
6
5
<refname>imagecrop</refname>
7
-
<refpurpose>Crop an image using the given coordinates and size, x, y, width and height</refpurpose>
6
+
<refpurpose>Crop an image to the given rectangle</refpurpose>
8
7
</refnamediv>
9
8

10
9
<refsect1 role="description">
11
10
&reftitle.description;
12
11
<methodsynopsis>
13
-
<type>resource</type><methodname>imagecrop</methodname>
14
-
<methodparam><type>resource</type><parameter>image</parameter></methodparam>
15
-
<methodparam><type>array</type><parameter>rect</parameter></methodparam>
12
+
<type class="union"><type>GdImage</type><type>false</type></type><methodname>imagecrop</methodname>
13
+
<methodparam><type>GdImage</type><parameter>image</parameter></methodparam>
14
+
<methodparam><type>array</type><parameter>rectangle</parameter></methodparam>
16
15
</methodsynopsis>
17
16
<para>
18
-

17
+
Crops an image to the given rectangular area and returns the resulting image.
18
+
The given <parameter>image</parameter> is not modified.
19
19
</para>
20
20

21
-
&warn.undocumented.func;
22
-

23
21
</refsect1>
24
22

25
23
<refsect1 role="parameters">
...
...
@@ -27,10 +25,12 @@
27
25
<variablelist>
28
26
&gd.image.description;
29
27
<varlistentry>
30
-
<term><parameter>rect</parameter></term>
28
+
<term><parameter>rectangle</parameter></term>
31
29
<listitem>
32
30
<para>
33
-
Array with keys "x", "y", "width" and "height".
31
+
The cropping rectangle as <type>array</type> with keys
32
+
<literal>x</literal>, <literal>y</literal>, <literal>width</literal> and
33
+
<literal>height</literal>.
34
34
</para>
35
35
</listitem>
36
36
</varlistentry>
...
...
@@ -40,12 +40,66 @@
40
40
<refsect1 role="returnvalues">
41
41
&reftitle.returnvalues;
42
42
<para>
43
-
Return cropped image resource on success&return.falseforfailure;.
43
+
Return cropped image object on success&return.falseforfailure;.
44
44
</para>
45
45
</refsect1>
46
46

47
-
</refentry>
47
+
<refsect1 role="changelog">
48
+
&reftitle.changelog;
49
+
<informaltable>
50
+
<tgroup cols="2">
51
+
<thead>
52
+
<row>
53
+
<entry>&Version;</entry>
54
+
<entry>&Description;</entry>
55
+
</row>
56
+
</thead>
57
+
<tbody>
58
+
&gd.changelog.image-param;
59
+
<row>
60
+
<entry>8.0.0</entry>
61
+
<entry>
62
+
On success, this function returns a <classname>GDImage</classname> instance now;
63
+
previously, a <type>resource</type> was returned.
64
+
</entry>
65
+
</row>
66
+
</tbody>
67
+
</tgroup>
68
+
</informaltable>
69
+
</refsect1>
48
70

71
+
<refsect1 role="examples">
72
+
&reftitle.examples;
73
+
<example xml:id="imagecrop.example.basic">
74
+
<title><function>imagecrop</function> example</title>
75
+
<para>
76
+
This example shows how to crop an image to a square area.
77
+
</para>
78
+
<programlisting role="php">
79
+
<![CDATA[
80
+
<?php
81
+
$im = imagecreatefrompng('example.png');
82
+
$size = min(imagesx($im), imagesy($im));
83
+
$im2 = imagecrop($im, ['x' => 0, 'y' => 0, 'width' => $size, 'height' => $size]);
84
+
if ($im2 !== FALSE) {
85
+
imagepng($im2, 'example-cropped.png');
86
+
imagedestroy($im2);
87
+
}
88
+
imagedestroy($im);
89
+
?>
90
+
]]>
91
+
</programlisting>
92
+
</example>
93
+
</refsect1>
94
+

95
+
<refsect1 role="seealso">
96
+
&reftitle.seealso;
97
+
<simplelist>
98
+
<member><function>imagecropauto</function></member>
99
+
</simplelist>
100
+
</refsect1>
101
+

102
+
</refentry>
49
103
<!-- Keep this comment at the end of the file
50
104
Local variables:
51
105
mode: sgml
52
106