-
Notifications
You must be signed in to change notification settings - Fork 529
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
Is there an inverse to getGdResource() #837
Comments
Why not use the |
Because (as described) that solution appears to require writing the work-in-progress image to disk... which is what I am trying to avoid... or am I misunderstanding your suggestion? |
How about this? $imagine_object = new Imagine\Gd\Imagine(); // Creates new Imagine GD object
$image_object = $imagine_object->load($image); // Creates a new Image GD object
$gd_resource = $image_object->getGdResource();
... do stuff ...
$modified_image_object = (new Imagine\Factory\ClassFactory())->createImage(
Imagine\Factory\ClassFactoryInterface::HANDLE_GD,
$gd_resource,
new Imagine\Image\Palette\RGB(),
new Imagine\Image\Metadata\MetadataBag(),
); |
Perfect - thanks! |
Is there a simple / reliable way to determine which Image library an Imagine object is using? |
if ($image instanceof \Imagine\Gd\Image) {
//...
} elseif ($image instanceof \Imagine\Imagick\Image) {
//...
} elseif ($image instanceof \Imagine\Gmagick\Image) {
//...
} |
Thanks - much neater |
Issue description
The getGdResource() method extracts the GDResource component from a GD type Image object.
However there does not appear to be any clean way to generate or update the Image object from a GDResource type entity.
This is unfortunate.
If (for example) if you need to apply a process to an image for which no Image methods exist (e.g. apply an arbitrary laplacian type filter) then the only option (in GD universe) is to export the image resource, apply the process using GD primitives and then ... you are stuck. The Imagine read() method apparently only reads GD resources from disk, so it would appear to proceed with processing you need to write the partially processed image to disk and read it back again (or if that doesn't work, write out partially processed image in an image file format and create a new Image instance by reading that back again).
A better solution would be for there to be a way to simply load a GD resource back into the Image object.
...
What version of Imagine are you using?
1.3.2
What's the PHP version you are using?
8.0.25
What's the imaging library you are using [gd/imagick/gmagick/any]?
GD2
What's the imaging library configuration
GD Version: "2.3.3"
FreeType Support: true
FreeType Linkage: "with freetype"
GIF Read Support: true
GIF Create Support: true
JPEG Support: true
PNG Support: true
WBMP Support: true
XPM Support: true
XBM Support: true
WebP Support: true
BMP Support: true
TGA Read Support: true
JIS-mapped Japanese Font Support: false
Minimal PHP code to reproduce the error:
The text was updated successfully, but these errors were encountered: