0

I have in database JPEG image stored using following i can view the image. But the size of the image is large above 10MB or 20MB. How to tell PHP to compress the image and from jQuery/Javascript decompress it? So that the bandwidth usage get reduced?

$.get( "https://www.example.com/jpeg/render3D4K", { userid: '1' }).done(function( data ) {
  $("#show_picture").attr('poster', data);        
  //<video id="show_picture" >
});
  • The JPEG format applies compression already. Trying to compress that already compressed data again is a fruitless endeavor - if you achieved any improvement at all doing that, it would be absolutely minimal. And taking into account the processing power needed to apply compression again, and having to do un-compression twice on the client instead of only once, makes this an even worse idea. If there is anything to improve in your current setup, then it is that images are stored in the database - that's not where they belong, they belong into the file system. – CBroe Feb 24 '17 at 21:10
  • relative topic http://stackoverflow.com/questions/6561828/compress-data-in-php-and-uncompress-in-javascript – RomanPerekhrest Feb 24 '17 at 21:17

1 Answers1

0

Use NodeJS

  • Run background downloader, which download compressed version and store in local by decompressing
  • from local then render it to the front end