php - Degrading a jpg image quality each time a user visits a page? -
I am trying to prepare the best way to downgrade the quality of JPG image in a web page like this < / P>
Is there a server-side method that is saving and re-saving at lower quality, then the page is displayed every time?
Thanks in advance.
The following script will degrade the original page from 1 'quality point' on 1 pixel load, from 99 Will start. It is not very strong, but the concept should clearly demonstrate.
Warning: this will replace the original image! Use a copy when the original is important!
session_start (); If (empty ($ _ session ['quality']) $ _SESSION ['quality'] = 99; $ File = 'degrade.jpg'; Imagejpeg (imagecreatefromjpeg ($ file), $ file, $ _SESSION ['quality'] ); $ _SESSION ['Quality'] -; Header ('Content Type: Image / JPEG'); Echo file_get_contents ($ file);
On first page load:
Tenth page load:
One hundred page loads:
Comments
Post a Comment