2👍
✅
ImageMagick can write to its stdout, so you don’t actually need the temporary file. Try this:
cmd = ['convert', local_file, '-crop', '50%x50%+10+10', '-']
new_image = subprocess.check_output( cmd )
response = HttpResponse( new_image, mimetype=mt )
Note: you still have to figure out the mime type. Without a file, that might be more difficult.
👤Robᵩ
0👍
f.read() is just a python2 string of bytes. You can pass anything there.
You would have to use some interface than allows you to retrieve directly bytes, rather than write to a file. For example, an imagemagick wrapper, like this:
👤Zah
- [Answered ]-Javascript event that triggers python script
- [Answered ]-Django 1.7 – makemigrations not detecting changes – managed models
- [Answered ]-Regex matching alphanumeric with special characters
- [Answered ]-Show the custom message in Django form
- [Answered ]-Stopping ignoring migration files in git for a Django Project
Source:stackexchange.com