0
나는 django-avatar 앱을 사용하고 있으며 미리보기 이미지를 저장하는 데 사용할 수 없습니다. 원본 이미지는 내 미디어 디렉토리에 정상적으로 저장됩니다.django-avatar : cant save thumbnail
def create_thumbnail(self, size, quality=None):
# invalidate the cache of the thumbnail with the given size first
invalidate_cache(self.user, size)
try:
orig = self.avatar.storage.open(self.avatar.name, 'rb')
image = Image.open(orig)
quality = quality or settings.AVATAR_THUMB_QUALITY
w, h = image.size
if w != size or h != size:
if w > h:
diff = int((w - h)/2)
image = image.crop((diff, 0, w - diff, h))
else:
diff = int((h - w)/2)
image = image.crop((0, diff, w, h - diff))
if image.mode != "RGB":
image = image.convert("RGB")
image = image.resize((size, size), settings.AVATAR_RESIZE_METHOD)
thumb = six.BytesIO()
image.save(thumb, settings.AVATAR_THUMB_FORMAT, quality=quality)
thumb_file = ContentFile(thumb.getvalue())
else:
thumb_file = File(orig)
thumb = self.avatar.storage.save(self.avatar_name(size), thumb_file)
except IOError:
return # What should we do here? Render a "sorry, didn't work" img?
어쩌면 내가 필요로하는 모든 단지 일부 라이브러리는 다음과 같습니다 단계 실행을 사용 오류가 나는 create_thumbnail에서이 줄을 발견
image.save(thumb, settings.AVATAR_THUMB_FORMAT, quality=quality)
여기에서 발생한 것으로 나타났다? 감사합니다.
정확한 오류 메시지를 보내주십시오. – Nathan