Hi Juan,

The best application of Zend_Cache to what you are doing might be something 
like the following:

$im = imagecreatefrompng("test.png");

Storing $im in cache probably won't help unless you are repeatedly resizing the 
same images, if they are user uploaded images there is no benefit from caching. 
You could use Zend_Cache_Frontend_File to refresh the cache when the file 
changes (if you are resizing the same images).

// do your resizing here

You could have a function/method that performs the resize based on input data. 
You could use Zend_Cache_Frontend_Function or Zend_Cache_Frontend_Class for 
this, however once again it will only really help if you are repeatedly 
resizing the same images.

imagepng($im);

This pumps the result to the page or to a file, you might use Zend_Cache and 
some output buffering to capture the output and store it in cache, but once 
again this only really works if you are repeatedly resizing the same images.

The end result is if you're resizing user uploaded images, they will almost 
never be the same, so caching can't help you. If you're constantly resizing the 
same images I would recommend you store them in PNG files (or whatever format 
you want) using a database ID or other identifier so they can be loaded by the 
browser without having to involve PHP at all.

Zend_Cache doesn't really help you here as the load saving comes when your 
input data is the same as that matching something that has already been cached 
and it can load the cached version and bypass the processing.

I hope this answers your question.

Cheers,
Steven

-----Original Message-----
From: Juan Felipe Alavarez Saldarriaga [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 7 November 2007 1:13 AM
To: fw-general
Subject: [fw-general] Zend_Cache Images How To ?

Hey! :)

I'm making something like this, a class to resize images using GD, the resize 
process is working fine, but the problem that I have is that the new images 
when are resized takes a lot of time to do it, so I was thinking on use the 
Zend_Cache for that, is possible ? I mean like cache a imagecreatefrompng() 
resource or maybe convert the image to base64 and then cache it ?

Thx for any suggestion.


Reply via email to