0

I got the below code from stack is there anyone who can help to save the compressed image in mongodb using mongoengine

 >>> from PIL import Image
 # My image is a 200x374 jpeg that is 102kb large
 >>> foo = Image.open("path\\to\\image.jpg")
 >>> foo.size
  (200,374)
 # I downsize the image with an ANTIALIAS filter (gives the highest quality)
 >>> foo = foo.resize((160,300),Image.ANTIALIAS)
 >>> foo.save("path\\to\\save\\image_scaled.jpg",quality=95)
 # The saved downsized image size is 24.8kb
 >>> foo.save("path\\to\\save\\image_scaled_opt.jpg",optimize=True,quality=95)
 # The saved downsized image size is 22.9kb
  • Take a look [here](https://stackoverflow.com/questions/4796914/store-images-in-a-mongodb-database) – Valijon Apr 09 '20 at 09:28
  • Thanks Valijon but i want the code to save the compression image which i got from PIL Image to database .In that stack i didnot find anything related to that – elavarasan Apr 10 '20 at 05:57

0 Answers0