php-image-resize icon indicating copy to clipboard operation
php-image-resize copied to clipboard

Create from GD object

Open jenstornell opened this issue 6 years ago • 2 comments
trafficstars

I've just written a converting library to convert all the common image formats from/to.

https://github.com/jenstornell/php-image-converter https://github.com/jenstornell/php-image-converter/issues/2

The pitfall of using it with this library is that I need to save the image two times, one for the format conversion and one for the resize.

That's because I can't create an image from a GD object. Here is a suggestion of how that could look like.

$image = ImageResize::createFromGD($gd_object);
$image->scale(50);
$image->save('image.jpg');

https://www.php.net/manual/en/function.imagejpeg.php https://www.php.net/manual/en/function.imagepng.php https://www.php.net/manual/en/function.imagewebp.php https://www.php.net/manual/en/function.imagegif.php

jenstornell avatar Apr 28 '19 03:04 jenstornell

According to the one of image functions, the $gd_object type is resource?

I think we should consider following points if the author @adityapatadia will accept this feature request.

  • Validate the $gd_object type is resource before manipulating the image. We can use the get_resource_type to handle this.

peter279k avatar Apr 29 '19 07:04 peter279k

How about adding conversion functions to this library itself?

adityapatadia avatar Jun 07 '19 11:06 adityapatadia