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:

first run

Tenth page load:

tenth run

One hundred page loads:

one hundred runs


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -