Django-imagekit: how to reduce image quality with a preprocessor_spec?

南楼画角 提交于 2019-12-11 04:39:57

问题


I've created this simple model class, with a Preprocessor to reduce my photos'quality (the photos'extension is .JPG):

from django.db import models
from imagekit.models import ImageModel
from imagekit.specs import ImageSpec
from imagekit import processors

class Preprocessor(ImageSpec):
    quality = 50
    processors = [processors.Format]

class Picture(ImageModel):
    image = models.ImageField(upload_to='pictures')

    class IKOptions:
        preprocessor_spec = Preprocessor

The problem : pictures' quality are not reduced. Any idea how to fix it?


回答1:


I just tried your example using the latest checkout from the django-imagekit project page and it worked just fine. I lowered the quality to 10 and the difference was obvious. Are you still having issues with this?




回答2:


You could try https://github.com/burgalon/plupload-s3mixin uses plupload, allows Flash image resizing, and integrates nicely with on-the-fly thumbnail generation



来源:https://stackoverflow.com/questions/1460328/django-imagekit-how-to-reduce-image-quality-with-a-preprocessor-spec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!