Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create from GD object #140

Open
jenstornell opened this issue Apr 28, 2019 · 2 comments
Open

Create from GD object #140

jenstornell opened this issue Apr 28, 2019 · 2 comments
Assignees
Labels

Comments

@jenstornell
Copy link

jenstornell commented Apr 28, 2019

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

https://github.com/jenstornell/php-image-converter
free-open-source/php-image-converter#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

@peter279k
Copy link
Contributor

peter279k commented Apr 29, 2019

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.

@adityapatadia
Copy link
Contributor

How about adding conversion functions to this library itself?

@peter279k peter279k self-assigned this Dec 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants