Brion Vibber wrote:
Ideally, you can in fact extract a size from the file.
If you can't get
it from the file yourself, you should be able to get it from your
external program in some way. (Worst case, render to a temporary PNG at
"native" size and check *its* size. Probably crappy, but hey.)
Yes, "worst case" is what I am doing now, rendering to a file in /tmp,
using PHP's getimagesize() to get its size, and deleting the temporary
file. However this is very CPU intensive.
Would there be a way for me to "save" this temporary file somewhere
inside the uploads directory, in a way that I could use it later in
doTransform?
I mean, in getImageSize() I would write the temporary file to somewhere
inside the upload directory (how could I automate the creation of a path
for that?) and not remove it after getting its size. Then, in
doTransform(), I would check if the requested dimensions match the ones
of the temporary file I created, if they do, I would just
copy/rename/hardlink the original file to the new one. Would that work?
How should I manage creating a path on the upload directory for that?
(I'm thinking something such as "math" or "graphviz" under the
root of
uploads.)
Thanks!
Filipe