reference/image/functions/imagefilter.xml
593ea510e853ff034e03f78a4be0daa41661c9d4
...
...
@@ -1,4 +1,4 @@
1
-
<?xml version="1.0" encoding="UTF-8"?>
1
+
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
3
<refentry xml:id="function.imagefilter" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
...
...
@@ -9,16 +9,13 @@
9
9
&reftitle.description;
10
10
<methodsynopsis>
11
11
<type>bool</type><methodname>imagefilter</methodname>
12
-
<methodparam><type>resource</type><parameter>image</parameter></methodparam>
13
-
<methodparam><type>int</type><parameter>filtertype</parameter></methodparam>
14
-
<methodparam choice="opt"><type>int</type><parameter>arg1</parameter></methodparam>
15
-
<methodparam choice="opt"><type>int</type><parameter>arg2</parameter></methodparam>
16
-
<methodparam choice="opt"><type>int</type><parameter>arg3</parameter></methodparam>
17
-
<methodparam choice="opt"><type>int</type><parameter>arg4</parameter></methodparam>
12
+
<methodparam><type>GdImage</type><parameter>image</parameter></methodparam>
13
+
<methodparam><type>int</type><parameter>filter</parameter></methodparam>
14
+
<methodparam rep="repeat"><type class="union"><type>array</type><type>int</type><type>float</type><type>bool</type></type><parameter>args</parameter></methodparam>
18
15
</methodsynopsis>
19
16
<para>
20
17
<function>imagefilter</function> applies the given filter
21
-
<parameter>filtertype</parameter> on the <parameter>image</parameter>.
18
+
<parameter>filter</parameter> on the <parameter>image</parameter>.
22
19
</para>
23
20
</refsect1>
24
21
<refsect1 role="parameters">
...
...
@@ -27,10 +24,10 @@
27
24
<variablelist>
28
25
&gd.image.description;
29
26
<varlistentry>
30
-
<term><parameter>filtertype</parameter></term>
27
+
<term><parameter>filter</parameter></term>
31
28
<listitem>
32
29
<para>
33
-
<parameter>filtertype</parameter> can be one of the following:
30
+
<parameter>filter</parameter> can be one of the following:
34
31
<itemizedlist>
35
32
<listitem>
36
33
<simpara>
...
...
@@ -41,20 +38,23 @@
41
38
<listitem>
42
39
<simpara>
43
40
<constant>IMG_FILTER_GRAYSCALE</constant>: Converts the image into
44
-
grayscale.
41
+
grayscale by changing the red, green and blue components to their
42
+
weighted sum using the same coefficients as the REC.601 luma (Y')
43
+
calculation. The alpha components are retained. For palette images the
44
+
result may differ due to palette limitations.
45
45
</simpara>
46
46
</listitem>
47
47
<listitem>
48
48
<simpara>
49
49
<constant>IMG_FILTER_BRIGHTNESS</constant>: Changes the brightness
50
-
of the image. Use <parameter>arg1</parameter> to set the level of
51
-
brightness.
50
+
of the image. Use <parameter>args</parameter> to set the level of
51
+
brightness. The range for the brightness is -255 to 255.
52
52
</simpara>
53
53
</listitem>
54
54
<listitem>
55
55
<simpara>
56
56
<constant>IMG_FILTER_CONTRAST</constant>: Changes the contrast of
57
-
the image. Use <parameter>arg1</parameter> to set the level of
57
+
the image. Use <parameter>args</parameter> to set the level of
58
58
contrast.
59
59
</simpara>
60
60
</listitem>
...
...
@@ -62,10 +62,10 @@
62
62
<simpara>
63
63
<constant>IMG_FILTER_COLORIZE</constant>: Like
64
64
<constant>IMG_FILTER_GRAYSCALE</constant>, except you can specify the
65
-
color. Use <parameter>arg1</parameter>, <parameter>arg2</parameter> and
65
+
color. Use <parameter>args</parameter>, <parameter>arg2</parameter> and
66
66
<parameter>arg3</parameter> in the form of
67
-
<parameter>red</parameter>, <parameter>blue</parameter>,
68
-
<parameter>green</parameter> and <parameter>arg4</parameter> for the
67
+
<parameter>red</parameter>, <parameter>green</parameter>,
68
+
<parameter>blue</parameter> and <parameter>arg4</parameter> for the
69
69
<parameter>alpha</parameter> channel. The range for each color is 0 to 255.
70
70
</simpara>
71
71
</listitem>
...
...
@@ -100,22 +100,31 @@
100
100
<listitem>
101
101
<simpara>
102
102
<constant>IMG_FILTER_SMOOTH</constant>: Makes the image smoother.
103
-
Use <parameter>arg1</parameter> to set the level of smoothness.
103
+
Use <parameter>args</parameter> to set the level of smoothness.
104
104
</simpara>
105
105
</listitem>
106
106
<listitem>
107
107
<simpara>
108
108
<constant>IMG_FILTER_PIXELATE</constant>: Applies pixelation effect
109
-
to the image, use <parameter>arg1</parameter> to set the block size
109
+
to the image, use <parameter>args</parameter> to set the block size
110
110
and <parameter>arg2</parameter> to set the pixelation effect mode.
111
111
</simpara>
112
112
</listitem>
113
+
<listitem>
114
+
<simpara>
115
+
<constant>IMG_FILTER_SCATTER</constant>: Applies scatter effect
116
+
to the image, use <parameter>args</parameter> and
117
+
<parameter>arg2</parameter> to define the effect strength and
118
+
additionally <parameter>arg3</parameter> to only apply the
119
+
on select pixel colors.
120
+
</simpara>
121
+
</listitem>
113
122
</itemizedlist>
114
123
</para>
115
124
</listitem>
116
125
</varlistentry>
117
126
<varlistentry>
118
-
<term><parameter>arg1</parameter></term>
127
+
<term><parameter>args</parameter></term>
119
128
<listitem>
120
129
<para>
121
130
<itemizedlist>
...
...
@@ -144,6 +153,13 @@
144
153
<constant>IMG_FILTER_PIXELATE</constant>: Block size in pixels.
145
154
</simpara>
146
155
</listitem>
156
+
<listitem>
157
+
<simpara>
158
+
<constant>IMG_FILTER_SCATTER</constant>: Effect substraction level.
159
+
This must not be higher or equal to the addition level set with
160
+
<parameter>arg2</parameter>.
161
+
</simpara>
162
+
</listitem>
147
163
</itemizedlist>
148
164
</para>
149
165
</listitem>
...
...
@@ -164,6 +180,11 @@
164
180
effect or not (defaults to &false;).
165
181
</simpara>
166
182
</listitem>
183
+
<listitem>
184
+
<simpara>
185
+
<constant>IMG_FILTER_SCATTER</constant>: Effect addition level.
186
+
</simpara>
187
+
</listitem>
167
188
</itemizedlist>
168
189
</para>
169
190
</listitem>
...
...
@@ -178,6 +199,12 @@
178
199
<constant>IMG_FILTER_COLORIZE</constant>: &gd.value.blue;
179
200
</simpara>
180
201
</listitem>
202
+
<listitem>
203
+
<simpara>
204
+
<constant>IMG_FILTER_SCATTER</constant>: Optional array indexed color values
205
+
to apply effect at.
206
+
</simpara>
207
+
</listitem>
181
208
</itemizedlist>
182
209
</para>
183
210
</listitem>
...
...
@@ -219,16 +246,11 @@
219
246
</row>
220
247
</thead>
221
248
<tbody>
249
+
&gd.changelog.image-param;
222
250
<row>
223
-
<entry>5.3.0</entry>
251
+
<entry>7.4.0</entry>
224
252
<entry>
225
-
Pixelation support (<constant>IMG_FILTER_PIXELATE</constant>) was added.
226
-
</entry>
227
-
</row>
228
-
<row>
229
-
<entry>5.2.5</entry>
230
-
<entry>
231
-
Alpha support for <constant>IMG_FILTER_COLORIZE</constant> was added.
253
+
Scatter support (<constant>IMG_FILTER_SCATTER</constant>) was added.
232
254
</entry>
233
255
</row>
234
256
</tbody>
...
...
@@ -402,21 +424,50 @@ imagedestroy($output);
402
424
</mediaobject>
403
425
</example>
404
426
</para>
427
+
<para>
428
+
<example>
429
+
<title><function>imagefilter</function> scatter example</title>
430
+
<programlisting role="php">
431
+
<![CDATA[
432
+
<?php
433
+
// Load the image
434
+
$logo = imagecreatefrompng('./php.png');
435
+

436
+
// Apply a very soft scatter effect to the image
437
+
imagefilter($logo, IMG_FILTER_SCATTER, 3, 5);
438
+

439
+
// Output the image with the scatter effect
440
+
header('Content-Type: image/png');
441
+
imagepng($logo);
442
+
imagedestroy($logo);
443
+
?>
444
+
]]>
445
+
</programlisting>
446
+
&example.outputs.similar;
447
+
<mediaobject>
448
+
<alt>Output of example : imagefilter() scatter</alt>
449
+
<imageobject>
450
+
<imagedata fileref="en/reference/image/figures/scatter.png"/>
451
+
</imageobject>
452
+
</mediaobject>
453
+
</example>
454
+
</para>
405
455
</refsect1>
406
456
<refsect1 role="notes">
407
457
&reftitle.notes;
408
-
&note.bundled.gd;
458
+
<note>
459
+
<simpara>
460
+
The result of <constant>IMG_FILTER_SCATTER</constant> is always random.
461
+
</simpara>
462
+
</note>
409
463
</refsect1>
410
464
<refsect1 role="seealso">
411
465
&reftitle.seealso;
412
-
<para>
413
-
<simplelist>
414
-
<member><function>imageconvolution</function></member>
415
-
</simplelist>
416
-
</para>
466
+
<simplelist>
467
+
<member><function>imageconvolution</function></member>
468
+
</simplelist>
417
469
</refsect1>
418
470
</refentry>
419
-

420
471
<!-- Keep this comment at the end of the file
421
472
Local variables:
422
473
mode: sgml
423
474