0

I have a Django project and i allow users to upload images. I don't want to limit image upload size for users. But want to compress the image after they select and store them. I want to understand which is better:

  1. Compress using java-script on the browser.
  2. Back end server using python libraries.

Also it will be helpful if links can be provided to implement the better approach.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Amarendra Reddy
  • 243
  • 2
  • 17
  • 1
    What image file formats do you want to support? If you only accept PNG, JPEG, and GIF you don't need to do any compression, since they are already compressed. – PM 2Ring Oct 01 '16 at 09:46

2 Answers2

1

I advice you to compress on the browser in order to :

  • avoid loading the server with many CPU and RAM heavy consuming calculations (as numerous as number of clients)
  • dwindle bandwith needed when transfert image threw the network
kevin ternet
  • 4,514
  • 2
  • 19
  • 27
1

I would compress in nginx (or apache) since this is the right place to do it. no need for python libraries to do this

small example:

gzip  on;
gzip_static on;
gzip_comp_level 9;
gzip_min_length 1400;
gzip_types  image/png image/gif image/jpeg

more on it --> in the nginx docs

doniyor
  • 36,596
  • 57
  • 175
  • 260