Django ImageField 内置属性height,width和size

ImageField实例使用heightwidthsize属性后,若后继操作需重新打开实例,其他模块方法才能调用实例,使用open()方法:
>>> from PIL import Image >>> car = Car.objects.get(name='57 Chevy') >>> car.photo.width 191 >>> car.photo.height 287 >>> image = Image.open(car.photo) # Raises ValueError: seek of closed file. >>> car.photo.open() <ImageFieldFile: cars/chevy.jpg> >>> image = Image.open(car.photo) >>> image <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=191x287 at 0x7F99A94E9048> ———————————————— 版权声明:本文为CSDN博主「hmk1900」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/jjxp2011/article/details/124367675

 

posted on 2023-02-24 08:55  ldx-wsj  阅读(71)  评论(0)    收藏  举报