issue with image_auto_rotate

See all posts See thread Reply

Re: issue with image_auto_rotate new!
by jon, 7 years, 5 months ago
Thank you for your help

I have reordered my code to first process the main image (only 1 image), store it and then create the (required by me) resized images (with a new instance of class.upload), this works better as it only needs to rotate the main image so seems to be saving in execution time (and possibly memory too). I get no errors with this, but essentially the same results :-) (of multiple images and auto-rotated!).

The error i am getting (before i re-ordered with the above) was
"Fatal error: Maximum execution time of 30 seconds exceeded in /home/site/public_html/class/upload.class.php on line 3527"

I don't think this is a memory issue.

I have looked at your upload class code (nice, but confusing to me :-))
I am of course naive towards your code and its complexity, but i wonder if moving the rotation until after the re-sizing would speed up the script (as my logic says it is faster and less memory to rotate a smaller file size/image, although i could of course be wrong).

I have tried to rearrange the code by adding in a "pre-auto-rotate" that sets the "image_src_y & image_src_x" measurements only (as if the image was rotated), then resizes and then the auto-rotate.
This seems to work faster, but due to my lack of understanding, is getting some unexpected results.... :-)
Would placing the auto-rotate after the resize be an idea, or would it make no difference in the execution time/memory anyhow?
If you think this will work, i am happy to spend some time understanding your upload class, to try and make this work correct.

Thanks Again
JonReply
Re: issue with image_auto_rotate new!
by jon, 7 years, 5 months ago
Hello again Colin

Just a quick follow up.
Indeed, i have managed to change the order of auto-flip image & auto-rotate image
to after the resize (only needed to change image_src_? to image_dst_? and place the code after "if ($this->image_resize) {...}").
This works MUCH faster and with multiple images (before 1 image was taking > 20 seconds, now 3 are taking < 10).

Will this have broken anything else (like crop, etc. although these seem to use image_dst too)?

Thanks Again
JonReply
Re: issue with image_auto_rotate new!
by colin, 7 years, 5 months ago
It is a good idea, and it works in your case.

But the auto-flip and auto-rotate must happen before any image processing occurs. Besides, resizing dimensions may be based on the source image dimensions, but the source image has to be rotated first.Reply