共 6 篇文章 |
|
阅561 转2 评0 公众公开 14-05-04 19:39 |
django上传图片和PIL生成缩略图。FILES) #如果用户提交的表单数据验证合法 if form.is_valid(): if ''image'' in request.FILES: image = request.FILES["image"] #debug() img= Image.open(image) img.thumbnail((250,250),Image.ANTIALIAS) url=''pic/''+image.name name= ''E:/django/... 阅1291 转4 评0 公众公开 14-04-28 13:30 |
阅598 转1 评0 公众公开 14-04-28 13:16 |
file uploads.from django.http import HttpResponseRedirectfrom django.shortcuts import render_to_response# Imaginary function to handle an uploaded file.from somewhere import handle_uploaded_filedef upload_file(request): if request.method == ''POST'': form = UploadFileForm(request.UploadedFile.chunks()... 阅490 转1 评0 公众公开 14-04-25 16:36 |
成功实现Django Admin图片上传与缩略图处理 | 子矜网。from __future__ import divisionimport osimport Imagefrom mysite.settings import MEDIA_ROOTfrom django.db.models.fields.files import ImageFieldFiledef make_thumb(path, size = 480): pixbuf = Image.open(path) width, height = pixbuf.size if width >size: delta = width /... 阅2493 转14 评0 公众公开 14-04-24 23:20 |
解决:安装Python Imaging Library (PIL)1)下载:官方:http://www.pythonware.com/products/pil/直接下载:http://effbot.org/downloads/Imaging-1.1.7.tar.gz2)运行命令安装:sudo python setup.py install ImageField causing error when rendering with "The Image" attribute has no file associated with it. 阅4114 转7 评0 公众公开 14-04-20 21:34 |