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 ?)

Command icon 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

Mschudders created an issue. See original summary.

mschudders’s picture

Issue summary: View changes
mschudders’s picture

mondrake’s picture

Status: Needs review » Needs work

Thank you!

I think we should check all usages of image_filter_keyword in the module https://git.drupalcode.org/search?search=image_filter_keyword&group_id=2...

since also round() and ceil() 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.

mondrake’s picture

mondrake’s picture

Status: Needs work » Needs review

Copy/pasted the getKeywordOffset() method from core #2350849: Deprecate image_filter_keyword()

  • mondrake committed 4546653 on 8.x-3.x authored by Mschudders
    Issue #3268087 by Mschudders: PHP 8.1 deprecation warning - float to int...
mondrake’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.