Imagick with PHP Memcache
Posted: 2012-05-15T02:50:48-07:00
Hi,
I have an "on-the-fly" image process which performs alpha compositing of an alpha-transparent image to a colour-filled image. The colour-filled image is static whereas the alpha-transparent images are dynamically called - and there are a lot of them.
I use the $img->compositeImage() and currently fetch all images from disk. However, because the colour-filled image is being used all the time, I am thinking it would be more efficient to hold that image in memory using Memcache rather than reading from disk. I hope that makes sense to do.
I am using Memcache for the first time and I am successful in reading an image and making it persist in memory ($memcache->get("my_image")). However, when I fetch the image and try to use compositeImage(), I get :-
"Fatal error: Call to a member function compositeImage() on a non-object"
My code snippet looks like this :-
$img = new Imagick();
$img = $memcache->get("my_image");
$img->compositeImage( new Imagick(...), imagick::COMPOSITE_COPYOPACITY, 0, 0 );
Is this the correct way for instantiating a new imagick object and assigning it the the image fetched from Memcahce??
Any help of advice much appreciated.
Jason
I have an "on-the-fly" image process which performs alpha compositing of an alpha-transparent image to a colour-filled image. The colour-filled image is static whereas the alpha-transparent images are dynamically called - and there are a lot of them.
I use the $img->compositeImage() and currently fetch all images from disk. However, because the colour-filled image is being used all the time, I am thinking it would be more efficient to hold that image in memory using Memcache rather than reading from disk. I hope that makes sense to do.
I am using Memcache for the first time and I am successful in reading an image and making it persist in memory ($memcache->get("my_image")). However, when I fetch the image and try to use compositeImage(), I get :-
"Fatal error: Call to a member function compositeImage() on a non-object"
My code snippet looks like this :-
$img = new Imagick();
$img = $memcache->get("my_image");
$img->compositeImage( new Imagick(...), imagick::COMPOSITE_COPYOPACITY, 0, 0 );
Is this the correct way for instantiating a new imagick object and assigning it the the image fetched from Memcahce??
Any help of advice much appreciated.
Jason