reference/image/functions/imagejpeg.xml
9960a09a5705102bf4dd0ce63e03d9ec716d0015
...
...
@@ -9,9 +9,9 @@
9
9
&reftitle.description;
10
10
<methodsynopsis>
11
11
<type>bool</type><methodname>imagejpeg</methodname>
12
-
<methodparam><type>resource</type><parameter>image</parameter></methodparam>
13
-
<methodparam choice="opt"><type>string</type><parameter>filename</parameter></methodparam>
14
-
<methodparam choice="opt"><type>int</type><parameter>quality</parameter></methodparam>
12
+
<methodparam><type>GdImage</type><parameter>image</parameter></methodparam>
13
+
<methodparam choice="opt"><type class="union"><type>resource</type><type>string</type><type>null</type></type><parameter>file</parameter><initializer>&null;</initializer></methodparam>
14
+
<methodparam choice="opt"><type>int</type><parameter>quality</parameter><initializer>-1</initializer></methodparam>
15
15
</methodsynopsis>
16
16
<para>
17
17
<function>imagejpeg</function> creates a <acronym>JPEG</acronym> file from
...
...
@@ -24,13 +24,9 @@
24
24
<variablelist>
25
25
&gd.image.description;
26
26
<varlistentry>
27
-
<term><parameter>filename</parameter></term>
27
+
<term><parameter>file</parameter></term>
28
28
<listitem>
29
29
<para>&gd.image.path;</para>
30
-
<para>
31
-
To skip this argument in order to provide the
32
-
<parameter>quality</parameter> parameter, use &null;.
33
-
</para>
34
30
</listitem>
35
31
</varlistentry>
36
32
<varlistentry>
...
...
@@ -39,7 +35,7 @@
39
35
<para>
40
36
<parameter>quality</parameter> is optional, and ranges from 0 (worst
41
37
quality, smaller file) to 100 (best quality, biggest file). The
42
-
default is the default IJG quality value (about 75).
38
+
default (<literal>-1</literal>) uses the default IJG quality value (about 75).
43
39
</para>
44
40
</listitem>
45
41
</varlistentry>
...
...
@@ -51,12 +47,44 @@
51
47
<para>
52
48
&return.success;
53
49
</para>
50
+
&gd.return.trueonerror;
51
+
</refsect1>
52
+

53
+
<refsect1 role="errors">
54
+
&reftitle.errors;
55
+
<simpara>
56
+
Throws a <classname>ValueError</classname> if <parameter>quality</parameter> is invalid.
57
+
</simpara>
54
58
</refsect1>
59
+

60
+
<refsect1 role="changelog">
61
+
&reftitle.changelog;
62
+
<informaltable>
63
+
<tgroup cols="2">
64
+
<thead>
65
+
<row>
66
+
<entry>&Version;</entry>
67
+
<entry>&Description;</entry>
68
+
</row>
69
+
</thead>
70
+
<tbody>
71
+
<row>
72
+
<entry>8.4.0</entry>
73
+
<entry>
74
+
Now throws a <classname>ValueError</classname> if <parameter>quality</parameter> is invalid.
75
+
</entry>
76
+
</row>
77
+
&gd.changelog.image-param;
78
+
</tbody>
79
+
</tgroup>
80
+
</informaltable>
81
+
</refsect1>
82
+

55
83
<refsect1 role="examples">
56
84
&reftitle.examples;
57
85
<para>
58
86
<example>
59
-
<title>Outputting a JPEG image</title>
87
+
<title>Outputting a JPEG image to the browser</title>
60
88
<programlisting role="php">
61
89
<![CDATA[
62
90
<?php
...
...
@@ -70,9 +98,6 @@ header('Content-Type: image/jpeg');
70
98

71
99
// Output the image
72
100
imagejpeg($im);
73
-

74
-
// Free up memory
75
-
imagedestroy($im);
76
101
?>
77
102
]]>
78
103
</programlisting>
...
...
@@ -87,7 +112,7 @@ imagedestroy($im);
87
112
</para>
88
113
<para>
89
114
<example>
90
-
<title>Saving a JPEG image</title>
115
+
<title>Saving a JPEG image to a file</title>
91
116
<programlisting role="php">
92
117
<![CDATA[
93
118
<?php
...
...
@@ -98,9 +123,6 @@ imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
98
123

99
124
// Save the image as 'simpletext.jpg'
100
125
imagejpeg($im, 'simpletext.jpg');
101
-

102
-
// Free up memory
103
-
imagedestroy($im);
104
126
?>
105
127
]]>
106
128
</programlisting>
...
...
@@ -108,7 +130,7 @@ imagedestroy($im);
108
130
</para>
109
131
<para>
110
132
<example>
111
-
<title>Outputting the image at 75% quality</title>
133
+
<title>Outputting the image at 75% quality to the browser</title>
112
134
<programlisting role="php">
113
135
<![CDATA[
114
136
<?php
...
...
@@ -120,11 +142,8 @@ imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
120
142
// Set the content type header - in this case image/jpeg
121
143
header('Content-Type: image/jpeg');
122
144

123
-
// Skip the filename parameter using NULL, then set the quality to 75%
145
+
// Skip the file parameter using NULL, then set the quality to 75%
124
146
imagejpeg($im, NULL, 75);
125
-

126
-
// Free up memory
127
-
imagedestroy($im);
128
147
?>
129
148
]]>
130
149
</programlisting>
...
...
@@ -133,7 +152,6 @@ imagedestroy($im);
133
152
</refsect1>
134
153
<refsect1 role="notes">
135
154
&reftitle.notes;
136
-
&note.config.jpeg;
137
155
<note>
138
156
<para>
139
157
If you want to output Progressive JPEGs, you need to set interlacing
...
...
@@ -141,20 +159,18 @@ imagedestroy($im);
141
159
</para>
142
160
</note>
143
161
</refsect1>
162
+

144
163
<refsect1 role="seealso">
145
164
&reftitle.seealso;
146
-
<para>
147
-
<simplelist>
148
-
<member><function>imagepng</function></member>
149
-
<member><function>imagegif</function></member>
150
-
<member><function>imagewbmp</function></member>
151
-
<member><function>imageinterlace</function></member>
152
-
<member><function>imagetypes</function></member>
153
-
</simplelist>
154
-
</para>
165
+
<simplelist>
166
+
<member><function>imagepng</function></member>
167
+
<member><function>imagegif</function></member>
168
+
<member><function>imagewbmp</function></member>
169
+
<member><function>imageinterlace</function></member>
170
+
<member><function>imagetypes</function></member>
171
+
</simplelist>
155
172
</refsect1>
156
173
</refentry>
157
-

158
174
<!-- Keep this comment at the end of the file
159
175
Local variables:
160
176
mode: sgml
161
177