A method for temporarily uploading images in Python
- 2020-04-02 14:35:39
- OfStack
It's a very simple code. Let's record it.
import Image
image = Image.open('a.jpg')
import cStringIO
buf = cStringIO.StringIO()
image.save(buf, image.format,quality=75)
data = buf.getvalue()
a = u.writeFile('/this/logo.jpg',data,True)
Using django, users upload images and transfer them to other servers. However, the transferred image needs to be processed, but I wonder if the quality setting can be saved when it is not image.save(). This is written when saved into memory, and then submitted directly to the image server.