@@ -603,12 +603,11 @@ function imagecrop($image, array $rect)
603
603
* @param float $threshold
604
604
* @param int $color
605
605
* @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.
608
607
* @throws ImageException
609
608
*
610
609
*/
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 )
612
611
{
613
612
error_clear_last ();
614
613
$ result = \imagecropauto ($ image , $ mode , $ threshold , $ color );
@@ -1155,11 +1154,7 @@ function imagegd2($image, $to = null, int $chunk_size = 128, int $type = IMG_GD2
1155
1154
function imagegif ($ image , $ to = null ): void
1156
1155
{
1157
1156
error_clear_last ();
1158
- if ($ to !== null ) {
1159
- $ result = \imagegif ($ image , $ to );
1160
- } else {
1161
- $ result = \imagegif ($ image );
1162
- }
1157
+ $ result = \imagegif ($ image , $ to );
1163
1158
if ($ result === false ) {
1164
1159
throw ImageException::createFromPhpError ();
1165
1160
}
@@ -1211,25 +1206,16 @@ function imagegrabwindow(int $window_handle, int $client_area = 0)
1211
1206
* @param resource $image An image resource, returned by one of the image creation functions,
1212
1207
* such as imagecreatetruecolor.
1213
1208
* @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.
1217
1209
* @param int $quality quality is optional, and ranges from 0 (worst
1218
1210
* 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).
1220
1212
* @throws ImageException
1221
1213
*
1222
1214
*/
1223
- function imagejpeg ($ image , $ to = null , int $ quality = null ): void
1215
+ function imagejpeg ($ image , $ to = null , int $ quality = - 1 ): void
1224
1216
{
1225
1217
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 );
1233
1219
if ($ result === false ) {
1234
1220
throw ImageException::createFromPhpError ();
1235
1221
}
@@ -1447,28 +1433,22 @@ function imageopenpolygon($image, array $points, int $num_points, int $color): v
1447
1433
*
1448
1434
* NULL is invalid if the quality and
1449
1435
* 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.
1451
1438
* For more information see the zlib manual.
1452
1439
* @param int $filters Allows reducing the PNG file size. It is a bitmask field which may be
1453
1440
* set to any combination of the PNG_FILTER_XXX
1454
1441
* constants. PNG_NO_FILTER or
1455
1442
* PNG_ALL_FILTERS may also be used to respectively
1456
1443
* disable or activate all filters.
1444
+ * The default value (-1) disables filtering.
1457
1445
* @throws ImageException
1458
1446
*
1459
1447
*/
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
1461
1449
{
1462
1450
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 );
1472
1452
if ($ result === false ) {
1473
1453
throw ImageException::createFromPhpError ();
1474
1454
}
@@ -1544,48 +1524,6 @@ function imagerectangle($image, int $x1, int $y1, int $x2, int $y2, int $color):
1544
1524
}
1545
1525
1546
1526
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
-
1589
1527
/**
1590
1528
* Rotates the image image using the given
1591
1529
* angle in degrees.
@@ -2258,10 +2196,8 @@ function imagewbmp($image, $to = null, int $foreground = null): void
2258
2196
error_clear_last ();
2259
2197
if ($ foreground !== null ) {
2260
2198
$ result = \imagewbmp ($ image , $ to , $ foreground );
2261
- } elseif ($ to !== null ) {
2262
- $ result = \imagewbmp ($ image , $ to );
2263
2199
} else {
2264
- $ result = \imagewbmp ($ image );
2200
+ $ result = \imagewbmp ($ image, $ to );
2265
2201
}
2266
2202
if ($ result === false ) {
2267
2203
throw ImageException::createFromPhpError ();
@@ -2310,7 +2246,7 @@ function imagewebp($image, $to = null, int $quality = 80): void
2310
2246
* @throws ImageException
2311
2247
*
2312
2248
*/
2313
- function imagexbm ($ image , ?string $ filename , int $ foreground = null ): void
2249
+ function imagexbm ($ image , ?string $ filename = null , int $ foreground = null ): void
2314
2250
{
2315
2251
error_clear_last ();
2316
2252
if ($ foreground !== null ) {
0 commit comments