Closed jcogs-design closed 1 year ago
Imagine\Gd\Imagine::read()
can only handle resources that point to files, not GD resource objects.
So your code should probably look like this:
$file_contents = file_get_contents($path);
$imagine_object = new Imagine\Gd\Imagine();
$imagine_object->load($file_contents);
Or if you need to handle existing GD resources you could use the class factory to create an image from that:
$gd_resource = imagecreatefromstring(file_get_contents($path)); // in php 8 creates a GDImage object
(new Imagine\Factory\ClassFactory())->createImage(
Imagine\Factory\ClassFactoryInterface::HANDLE_GD,
$gd_resource,
new Imagine\Image\Palette\RGB(),
new Imagine\Image\Metadata\MetadataBag(),
);
Hi - that's super helpful thanks. Am just getting head around Imagine and finding the documentation quite terse: great as a reference for specific methods, but not so useful for getting a handle on approach used by library. Such illustrative information as I have found so far dates from 2011, and not useful for current version of library. Do you know if there are good sources of information on use of the library beyond the docs? Thanks!
Do you know if there are good sources of information on use of the library beyond the docs?
I don’t know. I usually read the source code directly to find out how it is meant to be used. ☺️
Issue description
When trying to read an existing GDImage object into an Imagine\Gd\Imagine object I get an exception
Variable does not contain a stream resource
Unclear from manual whether there is a way / how to insert a GDImage object into an Imagine 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: