Important notice: this branch was discontinued long ago. A new version is available.
Please visit
http://wideimage.sourceforge.net for the new version of library and documentation.
This web site will remain accessible to serve as documentation for the old versions of the library.
For help on migration, please refer
to the
migration
guide.
Handle ownership
By default, every image object owns its handle (which is
a gd resource∞). By owning it, it's also responsible for destroying it properly. This is implemented via PHP's destructors -- when an image object is destroyed, it will automatically call
imagedestroy()∞ on its image handle. This means you don't have to destroy the images explicitly, they're destroyed when an image object is no longer used.
Example
$img = wiImage::
load(...
);
// get the handle
$handle =
$img->
getHandle();
// handle is valid
imagepng
($handle);
// destroy the object
unset($img);
// handle isn't valid anymore
imagepng
($handle);
Releasing a handle
Sometimes this behaviour is unwanted. When you want to have the control of the image resource even after the object is destroyed, you have to explicitly tell the object to release it:
$img = wiImage::
load(...
);
// get the handle
$handle =
$img->
getHandle();
// tell the object to release the handle
$img->
releaseHandle();
// destroy the object
unset($img);
// handle is still valid
imagepng
($handle);
But now you have to explicitly destroy the image resource. It's the price you pay.
imagedestroy($handle);
CategoryDoc
There are no comments on this page. [Add comment]