Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2114,7 +2114,7 @@ PHP_FUNCTION(imagejpeg)
}

if (quality < -1 || quality > 100) {
zend_argument_value_error(3, "must be at between -1 and 100");
zend_argument_value_error(3, "must be between -1 and 100");
ctx->gd_free(ctx);
RETURN_THROWS();
}
Expand Down
31 changes: 31 additions & 0 deletions ext/gd/tests/imagejpeg_quality_range.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--TEST--
imagejpeg(): the accepted range of $quality and the message for values outside it
--EXTENSIONS--
gd
--SKIPIF--
<?php
if (!function_exists('imagejpeg')) die('skip jpeg support unavailable');
?>
--FILE--
<?php
$image = imagecreatetruecolor(8, 8);
$file = __DIR__ . '/imagejpeg_quality_range.jpeg';

foreach ([-2, -1, 0, 100, 101] as $quality) {
try {
var_dump(imagejpeg($image, $file, $quality));
} catch (ValueError $e) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also you need to teach your agent to make the proper error format.

echo $e->getMessage(), "\n";
}
}
?>
--CLEAN--
<?php
@unlink(__DIR__ . '/imagejpeg_quality_range.jpeg');
?>
--EXPECT--
imagejpeg(): Argument #3 ($quality) must be between -1 and 100
bool(true)
bool(true)
bool(true)
imagejpeg(): Argument #3 ($quality) must be between -1 and 100
2 changes: 1 addition & 1 deletion ext/gd/tests/imageresolution_jpeg.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ array(2) {
[1]=>
int(299)
}
ValueError: imagejpeg(): Argument #3 ($quality) must be at between -1 and 100
ValueError: imagejpeg(): Argument #3 ($quality) must be between -1 and 100
--CLEAN--
<?php
@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'imageresolution_jpeg.jpeg');
Expand Down
Loading