0
我無法保存正在調整大小或直接通過我的admin
面板上傳的圖像。我想通過PLP
或任何其他方式調整它!如何自動上傳並保存圖像時調整圖像django?
def get_product_image_folder(instance, filename):
return "static/images/product/%s/base/%s" %(instance.product_id, filename)
product_image = StringIO.StringIO(i.read())
imageImage = Image.open(product_image)
thumbImage = imageImage.resize((100,100))
thumbfile = StringIO()
thumbImage.save(thumbfile, "JPEG")
thumbcontent = ContentFile(thumbfile.getvalue())
newphoto.thumb.save(filename, thumbcontent)
new_photo.save()