{{cd1>有一个
在将图像添加到FooModel.image
字段之前,我还使用wand.image
对图像进行一些转换和调整大小。在
所以我有一条线索:
foo = FooModel()
with Image(file='path/to/image.png') as tmpImage:
# some transformation on tmpImage
file_name = 'newTmpFile.png'
tmpImage.save(filename=file_name)
f = open(file_name, 'rb')
foo.image.save('new_file_name.png', File(f), save=True)
所以我基本上做了转换,把图像保存到一个临时的地方,再次打开它,然后传递到我的模型场。这似乎是非常多余和不必要的,但是我没有设法将tmpImage
传递给FooModel
实例。在
我试过File(tmpImage)
,只是tmpImage
,但是没有任何效果。还有别的主意吗?在
目前没有回答
相关问题 更多 >
编程相关推荐