Skip to content

[BUG] Phalcon\Image::crop() half params must be int, half can be int or float. #2259

Closed
@liesislukas

Description

I just had very bad morning of not knowing, that this function requires integers for offsets. I had floats.. I think it should be done in next release, that you could use floats or integers for all 4 params, or at least throw exceptions, docs written or something.

I use Phalcon 1.3.1 my final solution:

// i'm rounding those coordinates and they all become integer-like floats.
$x = round($x);
$y = round($y);
$w = round($w);
$h = round($h);
$uploaded_image->crop($w, $h, (int)$x, (int)$y);

my $x and $y comes in float, even if they are integer-like (value of $x is 0,1,2,3...) it still has float type and i was not able to use it. I had no errors, no nothing, just not working. It's PHP, we should be able to use int, float or even string with numbers - any numeric value in such situations.

Oh, and $w and $h are floats too, but it's all good, so i think it's definitely a bug, that half params are working with floats, some with only int, but no errors about it.

p.s. have't tried other numeric values like $x = '1';

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions