Skip to content

Commit 3b968a0

Browse files
committed
ext/gd: fix the wording of the imagejpeg() quality error
The message read "must be at between -1 and 100". The sibling writers, imageavif() in particular, use the same bounds without the stray word.
1 parent 311434a commit 3b968a0

3 files changed

Lines changed: 33 additions & 2 deletions

File tree

ext/gd/gd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2114,7 +2114,7 @@ PHP_FUNCTION(imagejpeg)
21142114
}
21152115

21162116
if (quality < -1 || quality > 100) {
2117-
zend_argument_value_error(3, "must be at between -1 and 100");
2117+
zend_argument_value_error(3, "must be between -1 and 100");
21182118
ctx->gd_free(ctx);
21192119
RETURN_THROWS();
21202120
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
imagejpeg(): the accepted range of $quality and the message for values outside it
3+
--EXTENSIONS--
4+
gd
5+
--SKIPIF--
6+
<?php
7+
if (!function_exists('imagejpeg')) die('skip jpeg support unavailable');
8+
?>
9+
--FILE--
10+
<?php
11+
$image = imagecreatetruecolor(8, 8);
12+
$file = __DIR__ . '/imagejpeg_quality_range.jpeg';
13+
14+
foreach ([-2, -1, 0, 100, 101] as $quality) {
15+
try {
16+
var_dump(imagejpeg($image, $file, $quality));
17+
} catch (ValueError $e) {
18+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
19+
}
20+
}
21+
?>
22+
--CLEAN--
23+
<?php
24+
@unlink(__DIR__ . '/imagejpeg_quality_range.jpeg');
25+
?>
26+
--EXPECT--
27+
ValueError: imagejpeg(): Argument #3 ($quality) must be between -1 and 100
28+
bool(true)
29+
bool(true)
30+
bool(true)
31+
ValueError: imagejpeg(): Argument #3 ($quality) must be between -1 and 100

ext/gd/tests/imageresolution_jpeg.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ array(2) {
4343
[1]=>
4444
int(299)
4545
}
46-
ValueError: imagejpeg(): Argument #3 ($quality) must be at between -1 and 100
46+
ValueError: imagejpeg(): Argument #3 ($quality) must be between -1 and 100
4747
--CLEAN--
4848
<?php
4949
@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'imageresolution_jpeg.jpeg');

0 commit comments

Comments
 (0)