Problem/Motivation
if (imagecopy($this->getToolkit()->getResource(), $original_res, $arguments['x_pos'], $arguments['y_pos'], 0, 0, imagesx($original_res), imagesy($original_res))) {
imagedestroy($original_res);
return TRUE;
}Imagecopy requires that the 3th and 4th argument are an integer.
But when the argument is a float it throws a warning.
Why is a float?:
function image_filter_keyword($anchor, $current_size, $new_size) {
More specifically:
case 'center':
return $current_size / 2 - $new_size / 2;
When (580 / 2) - 431/2 : 74,5
So this creates a float in function: public function applyEffect(ImageInterface $image) { in SetCanvasImageEffects.php
Patch attached to resolve this warning
Remaining tasks
Review
Question: We could also solve it inside of "SetCanvasImageEffects" but aren't we limiting the output then by default? (In cases we don't want it ?)
Issue fork image_effects-3268087
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mschudders commentedComment #3
mschudders commentedComment #5
mondrakeThank you!
I think we should check all usages of
image_filter_keywordin the module https://git.drupalcode.org/search?search=image_filter_keyword&group_id=2...since also
round()andceil()return floats and not ints. In future PHP this deprecation will become a type error, so better work it out now.Also, I would not change the GD toolkit operation code as in the MR - rather change
SetCanvasTrait::validate()to ensure x_pos and y_pos are ints.Comment #6
mondrakeFiled a core issue at #3268390: image_filter_keyword returns floats causing PHP 8.1 deprecations
Comment #7
mondrakeActually a #2350849: Deprecate image_filter_keyword() was existing already
Comment #8
mondrakeCopy/pasted the
getKeywordOffset()method from core #2350849: Deprecate image_filter_keyword()Comment #10
mondrake