Hello,
I'm using the PHP API Imagick. I'm not able to use the command line so I solely rely on the object oriented approach, which is nice but I'm not really sure about what is best performance wise.
One Example: if I had a loop that cuts an image in half and converts every half from png to jpg. At a point in my script I'll use $image->cropImage( $width , $height , $x , $y ); and after that the $image object only contains one half of the picture. Now my approach would be to save this image to a file and read it in later when I have to use it ($half_image = new Imagick('path to image'))) but with a lot of files that will be many read/write operations which can't be good und just doesn't feel right.
So it might be better to save the resulting halfs of the image in objects or better clone the original object beforehand and perform the operations afterwards?
Another example is compression: i read a file into an imagic object and set the (jpg) compression to let's say 1. Now I want to compare this image with its original. Would this be possible without saving the object with $image->writeImage($compress_src) and then $compressed_image = new Imagick(compress_src)? It feels kind of weird to write and then read again, but I guess the compression only happens when actually writing it to the filesystem. What I need is some kind of "simulateWrite" to an object is this somehow possible?
I hope you got my point.
Optimized File Handling
Re: Optimized File Handling
I would guess you will have to do some tests.
In a project I was working on using exec() I was surprised to find it was quicker to write and read an image as apposed to keeping it in the memory!
In a project I was working on using exec() I was surprised to find it was quicker to write and read an image as apposed to keeping it in the memory!
Re: Optimized File Handling
I use PHP Imagick to generate invoices, using lots of read and write operations (additional images etc). I realized that best optimization was move script-engine to linux system, same script generates much much faster than on Windows, even on slower machine.
Najciekawsze gotowe projekty domów jednorodzinnych w serwisie Galerii Domów