Skip to content

Many deprecation warnings: Implicit conversion from float to int loses precision #4

@peterwilsoncc

Description

@peterwilsoncc

In PHP 8.1 the implicit conversion of floats to integers was deprecated with the message Implicit conversion from float to int loses precision.

During the generation of images version 1.1.4 of Branded Social Images throws a lot of deprecation messages as a result.

PHP Deprecated:  Implicit conversion from float 484.03999999999996 to int loses precision in .../plugins/branded-social-images/lib/class.og-image-gd.php on line 189
[snip]
[28-Jun-2025 23:15:42 UTC] PHP  12. imagefilledrectangle($image = class GdImage {  }, $x1 = 40, $y1 = 484.04, $x2 = 723, $y2 = 590, $color = 1224736768) .../plugins/branded-social-images/lib/class.og-image-gd.php:189

PHP Deprecated:  Implicit conversion from float 557.3733333333333 to int loses precision in .../plugins/branded-social-images/vendor/stil/gd-text/src/Box.php on line 400
[snip]
[28-Jun-2025 23:15:42 UTC] PHP  15. imagefttext($image = class GdImage {  }, $size = 40, $angle = 0, $x = 60, $y = 557.37333333333, $color = 16777215, $font_filename = '../uploads/bsi-uploads/Roboto-Bold.ttf', $text = 'Still Testing - Peter Wilson') .../plugins/branded-social-images/vendor/stil/gd-text/src/Box.php:400

To resolve this, you can either cast all of the numeric values when calling these functions and other GD functions to an integer. It looks like you'll need to do the same for calls to the gd-text library you use too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions