PHP: Hypertext Preprocessor (original) (raw)
image2wbmp
(PHP 4 >= 4.0.5, PHP 5, PHP 7)
image2wbmp — Output image to browser or file
Warning
This function has been_DEPRECATED_ as of PHP 7.3.0, and REMOVED as of PHP 8.0.0. Relying on this function is highly discouraged.
Description
Parameters
image
An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().
filename
Path to the saved file. If not given, the raw image stream will be output directly.
foreground
You can set the foreground color with this parameter by setting an identifier obtained from imagecolorallocate(). The default foreground color is black.
Return Values
Returns [true](reserved.constants.php#constant.true)
on success or [false](reserved.constants.php#constant.false)
on failure.
Caution
However, if libgd fails to output the image, this function returns [true](reserved.constants.php#constant.true)
.
Examples
Example #1 image2wbmp() example
<?php $file = 'php.png'; <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>i</mi><mi>m</mi><mi>a</mi><mi>g</mi><mi>e</mi><mo>=</mo><mi>i</mi><mi>m</mi><mi>a</mi><mi>g</mi><mi>e</mi><mi>c</mi><mi>r</mi><mi>e</mi><mi>a</mi><mi>t</mi><mi>e</mi><mi>f</mi><mi>r</mi><mi>o</mi><mi>m</mi><mi>p</mi><mi>n</mi><mi>g</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">image = imagecreatefrompng(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.854em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ima</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal">e</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">ima</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal">ecre</span><span class="mord mathnormal">a</span><span class="mord mathnormal">t</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal">ro</span><span class="mord mathnormal">m</span><span class="mord mathnormal">p</span><span class="mord mathnormal">n</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mopen">(</span></span></span></span>file);header('Content-Type: ' . image_type_to_mime_type(IMAGETYPE_WBMP)); image2wbmp($image); // output the stream directly ?>