@@ -603,12 +603,11 @@ function imagecrop($image, array $rect)
603603 * @param float $threshold
604604 * @param int $color
605605 * @return resource Returns a cropped image resource on success .
606- * If no cropping would occur, or the complete image would be cropped, that is
607- * treated as failure, i.e. imagecrop returns FALSE.
606+ * If the complete image was cropped, imagecrop returns FALSE.
608607 * @throws ImageException
609608 *
610609 */
611- function imagecropauto ($ image , int $ mode = - 1 , float $ threshold = .5 , int $ color = -1 )
610+ function imagecropauto ($ image , int $ mode = IMG_CROP_DEFAULT , float $ threshold = .5 , int $ color = -1 )
612611{
613612 error_clear_last ();
614613 $ result = \imagecropauto ($ image , $ mode , $ threshold , $ color );
@@ -1155,11 +1154,7 @@ function imagegd2($image, $to = null, int $chunk_size = 128, int $type = IMG_GD2
11551154function imagegif ($ image , $ to = null ): void
11561155{
11571156 error_clear_last ();
1158- if ($ to !== null ) {
1159- $ result = \imagegif ($ image , $ to );
1160- } else {
1161- $ result = \imagegif ($ image );
1162- }
1157+ $ result = \imagegif ($ image , $ to );
11631158 if ($ result === false ) {
11641159 throw ImageException::createFromPhpError ();
11651160 }
@@ -1211,25 +1206,16 @@ function imagegrabwindow(int $window_handle, int $client_area = 0)
12111206 * @param resource $image An image resource, returned by one of the image creation functions,
12121207 * such as imagecreatetruecolor.
12131208 * @param mixed $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly.
1214- *
1215- * To skip this argument in order to provide the
1216- * quality parameter, use NULL.
12171209 * @param int $quality quality is optional, and ranges from 0 (worst
12181210 * quality, smaller file) to 100 (best quality, biggest file). The
1219- * default is the default IJG quality value (about 75).
1211+ * default (-1) uses the default IJG quality value (about 75).
12201212 * @throws ImageException
12211213 *
12221214 */
1223- function imagejpeg ($ image , $ to = null , int $ quality = null ): void
1215+ function imagejpeg ($ image , $ to = null , int $ quality = - 1 ): void
12241216{
12251217 error_clear_last ();
1226- if ($ quality !== null ) {
1227- $ result = \imagejpeg ($ image , $ to , $ quality );
1228- } elseif ($ to !== null ) {
1229- $ result = \imagejpeg ($ image , $ to );
1230- } else {
1231- $ result = \imagejpeg ($ image );
1232- }
1218+ $ result = \imagejpeg ($ image , $ to , $ quality );
12331219 if ($ result === false ) {
12341220 throw ImageException::createFromPhpError ();
12351221 }
@@ -1447,28 +1433,22 @@ function imageopenpolygon($image, array $points, int $num_points, int $color): v
14471433 *
14481434 * NULL is invalid if the quality and
14491435 * filters arguments are not used.
1450- * @param int $quality Compression level: from 0 (no compression) to 9. The current default is 6.
1436+ * @param int $quality Compression level: from 0 (no compression) to 9.
1437+ * The default (-1) uses the zlib compression default.
14511438 * For more information see the zlib manual.
14521439 * @param int $filters Allows reducing the PNG file size. It is a bitmask field which may be
14531440 * set to any combination of the PNG_FILTER_XXX
14541441 * constants. PNG_NO_FILTER or
14551442 * PNG_ALL_FILTERS may also be used to respectively
14561443 * disable or activate all filters.
1444+ * The default value (-1) disables filtering.
14571445 * @throws ImageException
14581446 *
14591447 */
1460- function imagepng ($ image , $ to = null , int $ quality = null , int $ filters = null ): void
1448+ function imagepng ($ image , $ to = null , int $ quality = - 1 , int $ filters = - 1 ): void
14611449{
14621450 error_clear_last ();
1463- if ($ filters !== null ) {
1464- $ result = \imagepng ($ image , $ to , $ quality , $ filters );
1465- } elseif ($ quality !== null ) {
1466- $ result = \imagepng ($ image , $ to , $ quality );
1467- } elseif ($ to !== null ) {
1468- $ result = \imagepng ($ image , $ to );
1469- } else {
1470- $ result = \imagepng ($ image );
1471- }
1451+ $ result = \imagepng ($ image , $ to , $ quality , $ filters );
14721452 if ($ result === false ) {
14731453 throw ImageException::createFromPhpError ();
14741454 }
@@ -1544,48 +1524,6 @@ function imagerectangle($image, int $x1, int $y1, int $x2, int $y2, int $color):
15441524}
15451525
15461526
1547- /**
1548- * imageresolution allows to set and get the resolution of
1549- * an image in DPI (dots per inch). If none of the optional parameters is given,
1550- * the current resolution is returned as indexed array. If only
1551- * res_x is given, the horizontal and vertical resolution
1552- * are set to this value. If both optional parameters are given, the horizontal
1553- * and vertical resolution are set to these values, respectively.
1554- *
1555- * The resolution is only used as meta information when images are read from and
1556- * written to formats supporting this kind of information (curently PNG and
1557- * JPEG). It does not affect any drawing operations. The default resolution
1558- * for new images is 96 DPI.
1559- *
1560- * @param resource $image An image resource, returned by one of the image creation functions,
1561- * such as imagecreatetruecolor.
1562- * @param int $res_x The horizontal resolution in DPI.
1563- * @param int $res_y The vertical resolution in DPI.
1564- * @return mixed When used as getter (that is without the optional parameters), it returns
1565- * TRUE on success, .
1566- * When used as setter (that is with one or both optional parameters given),
1567- * it returns an indexed array of the horizontal and vertical resolution on
1568- * success, .
1569- * @throws ImageException
1570- *
1571- */
1572- function imageresolution ($ image , int $ res_x = null , int $ res_y = null )
1573- {
1574- error_clear_last ();
1575- if ($ res_y !== null ) {
1576- $ result = \imageresolution ($ image , $ res_x , $ res_y );
1577- } elseif ($ res_x !== null ) {
1578- $ result = \imageresolution ($ image , $ res_x );
1579- } else {
1580- $ result = \imageresolution ($ image );
1581- }
1582- if ($ result === false ) {
1583- throw ImageException::createFromPhpError ();
1584- }
1585- return $ result ;
1586- }
1587-
1588-
15891527/**
15901528 * Rotates the image image using the given
15911529 * angle in degrees.
@@ -2258,10 +2196,8 @@ function imagewbmp($image, $to = null, int $foreground = null): void
22582196 error_clear_last ();
22592197 if ($ foreground !== null ) {
22602198 $ result = \imagewbmp ($ image , $ to , $ foreground );
2261- } elseif ($ to !== null ) {
2262- $ result = \imagewbmp ($ image , $ to );
22632199 } else {
2264- $ result = \imagewbmp ($ image );
2200+ $ result = \imagewbmp ($ image, $ to );
22652201 }
22662202 if ($ result === false ) {
22672203 throw ImageException::createFromPhpError ();
@@ -2310,7 +2246,7 @@ function imagewebp($image, $to = null, int $quality = 80): void
23102246 * @throws ImageException
23112247 *
23122248 */
2313- function imagexbm ($ image , ?string $ filename , int $ foreground = null ): void
2249+ function imagexbm ($ image , ?string $ filename = null , int $ foreground = null ): void
23142250{
23152251 error_clear_last ();
23162252 if ($ foreground !== null ) {
0 commit comments