I've already used PIL
to reduce image size when saving an image,some thing like this:
image = Image.open(filename)
image.thumbnail(size, Image.ANTIALIAS)
image.save(filename)
now I want to show an image list in template,list of images is created in views.py
:
for company in companies:
list+='<img src="'+company.logo.url+'" />'
return render_to_response('index',{'list':list})
in template
:
<span>{{list|safe}}</span>
Is it possible to reduce the size of images when showing them in template to load them quickly?
Is it possible to reduce the size of images when showing them in template to load them quickly?
Doing this dynamically will almost certainly be slower than just sending the image. When you save the image, just save another version that's smaller and serve that version in your list.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.