Looking for code to flip/mirror/rotate an image in php?

Question by PJ Hardon: Looking for code to flip/mirror/rotate an image in php?
Hi everyone I’m looking for code to dynamically mirror, flip or rotate an image in the header of my site using php, jscript or html so that it only needs to be downloaded once for better optimization.

Cheers!

Best answer:

Answer by Phil Z
This can be done, if your php is compiled on your server with gdimage and/or imagemagick.

However, it’s not going to better optimize. In fact, it would slow things down.

Here’s why:

php runs on the server itself. Therefore, if you have php dynamically modify an image, it will actually send each modified image individually to the end user anyway. It will take longer, since it takes the server’s time to re-make the rotated header image (re-invent the wheel) on every page load.

It would, in fact, be better to save the different versions of the image. Now, if they’re all meant to be placed next to each other in the header, perhaps create one large image, and drop all of the other images into it.

In summary, php is server-side, and won’t help you with the optimization (as opposed to javascript, for example).

Add your own answer in the comments!

Revisions

There are no revisions for this post.

Tags: , , ,

No comments yet.

Leave a Reply