Skip to content
Open
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
4 changes: 2 additions & 2 deletions ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ PHP_FUNCTION(imagecolormatch)
zend_argument_value_error(2, "must be Palette");
RETURN_THROWS();
case -3:
zend_argument_value_error(2, "must be the same size as argument #1 ($im1)");
zend_argument_value_error(2, "must be the same size as argument #1 ($image1)");
RETURN_THROWS();
case -4:
zend_argument_value_error(2, "must have at least one color");
Expand Down 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
9 changes: 8 additions & 1 deletion ext/gd/tests/imagecolormatch_error4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ try {
echo $exception::class, ': ', $exception->getMessage(), "\n";
}

/* the message names argument #1, so that name has to be the real one */
foreach ((new ReflectionFunction('imagecolormatch'))->getParameters() as $parameter) {
echo '$', $parameter->getName(), "\n";
}

?>
--EXPECT--
ValueError: imagecolormatch(): Argument #2 ($image2) must be the same size as argument #1 ($im1)
ValueError: imagecolormatch(): Argument #2 ($image2) must be the same size as argument #1 ($image1)
$image1
$image2
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 (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
}
?>
--CLEAN--
<?php
@unlink(__DIR__ . '/imagejpeg_quality_range.jpeg');
?>
--EXPECT--
ValueError: imagejpeg(): Argument #3 ($quality) must be between -1 and 100
bool(true)
bool(true)
bool(true)
ValueError: 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