svn: /phpdoc/en/trunk/reference/image/functions/ imagecropauto.xml

From: Date: Mon, 11 Jul 2016 17:54:29 +0000
Subject: svn: /phpdoc/en/trunk/reference/image/functions/ imagecropauto.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-14330@lists.php.net to get a copy of this message
cmb Mon, 11 Jul 2016 17:54:29 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=339649 Log: Fix #69182: imagecropauto function not properly documented Bug: https://bugs.php.net/69182 (Verified) imagecropauto function not properly documented Changed paths: U phpdoc/en/trunk/reference/image/functions/imagecropauto.xml Modified: phpdoc/en/trunk/reference/image/functions/imagecropauto.xml =================================================================== --- phpdoc/en/trunk/reference/image/functions/imagecropauto.xml 2016-07-10 22:41:41 UTC (rev 339648) +++ phpdoc/en/trunk/reference/image/functions/imagecropauto.xml 2016-07-11 17:54:29 UTC (rev 339649) @@ -17,11 +17,9 @@ <methodparam choice="opt"><type>int</type><parameter>color</parameter><initializer>-1</initializer></methodparam> </methodsynopsis> <para> - + Automatically crops an image according to the given + <parameter>mode</parameter>. </para> - - &warn.undocumented.func; - </refsect1> <refsect1 role="parameters"> @@ -32,24 +30,85 @@ <term><parameter>mode</parameter></term> <listitem> <para> - One of <constant>IMG_CROP_*</constant> constants. + One of the following constants: </para> + <variablelist> + <varlistentry> + <term><constant>IMG_CROP_DEFAULT</constant></term> + <listitem> + <simpara> + Attempts to use <constant>IMG_CROP_TRANSPARENT</constant> and if it + fails it falls back to <constant>IMG_CROP_SIDES</constant>. + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term><constant>IMG_CROP_TRANSPARENT</constant></term> + <listitem> + <simpara> + Crops out a transparent background. + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term><constant>IMG_CROP_BLACK</constant></term> + <listitem> + <simpara> + Crops out a black background. + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term><constant>IMG_CROP_WHITE</constant></term> + <listitem> + <simpara> + Crops out a white background. + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term><constant>IMG_CROP_SIDES</constant></term> + <listitem> + <simpara> + Uses the 4 corners of the image to attempt to detect the background to + crop. + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term><constant>IMG_CROP_THRESHOLD</constant></term> + <listitem> + <simpara> + Crops an image using the given <parameter>threshold</parameter> and + <parameter>color</parameter>. + </simpara> + </listitem> + </varlistentry> + </variablelist> </listitem> </varlistentry> <varlistentry> <term><parameter>threshold</parameter></term> <listitem> <para> - Used in <constant>IMG_CROP_THRESHOLD</constant> mode. + Specifies the tolerance in percent to be used while comparing the image + color and the color to crop. The method used to calculate the color + difference is based on the color distance in the RGB(a) cube. </para> + <para> + Used only in <constant>IMG_CROP_THRESHOLD</constant> mode. + </para> </listitem> </varlistentry> <varlistentry> <term><parameter>color</parameter></term> <listitem> <para> - Used in <constant>IMG_CROP_THRESHOLD</constant> mode. + Either an RGB color value or a palette index. </para> + <para> + Used only in <constant>IMG_CROP_THRESHOLD</constant> mode. + </para> </listitem> </varlistentry> </variablelist> @@ -58,10 +117,39 @@ <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> - Return cropped image resource on success&return.falseforfailure;. + Returns a cropped image resource on success&return.falseforfailure;. + If no cropping would occur, or the complete image would be cropped, that is + treated as failure, i.e. <function>imagecrop</function> returns &false;. </para> </refsect1> + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title>Proper handling of auto-cropping</title> + <para> + As noted in the return value section, <function>imagecropauto</function> + returns &false; when there is either nothing to crop or the whole image + would be cropped. In this example we have an image resource + <literal>$im</literal> which should be automatically cropped only if there + is something to crop; otherwise we want to proceed with the original image. + </para> + <programlisting role="php"> +<![CDATA[ +<?php +$cropped = imagecropauto($im, IMG_CROP_DEFAULT); +if ($cropped !== false) { // in case a new image resource was returned + imagedestroy($im); // we destroy the original image + $im = $cropped; // and assign the cropped image to $im +} +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file

« previous php.doc.cvs (#14330) next »