matthewwithanm / django-imagekit

Automated image processing for Django. Currently v4.0
http://django-imagekit.rtfd.org/
BSD 3-Clause "New" or "Revised" License
2.26k stars 276 forks source link

Webp #421

Open iho opened 7 years ago

iho commented 7 years ago

Hi Does not work with format='WEBP'

How to fix it?

iho commented 7 years ago
In [3]: from PIL import features
   ...: print (features.check_module('webp'))
True
vstoykov commented 7 years ago

Hello @iho, can you provide some example code and a traceback or error that you see?

iho commented 7 years ago

@vstoykov I am trying to upload this file


class Image(models.Model):
    file = models.ImageField(upload_to='images')
    preview = ImageSpecField(source='file',
                             processors=[ResizeToFit(150, 150)],
                             format='WEBP',
                             options={'quality': 80})

    def __str__(self):
        return '/' + self.file.url

    class Meta:
        verbose_name = 'Зображення'
        verbose_name_plural = 'Зображення'

Then I upload few images in webp, png, jpeg formats via admin panel and run this code:

 for i in Image.objects.all(): print(i.preview.path)

When I try to open this files in gimp or ristretto I see these errors: Gimp Ristretto I though Ristretto cannot to open webp format, but I can open this file from Google samples http://www.gstatic.com/webp/gallery/4.webp

Archive with files from CACHE: squash.zip

iho commented 7 years ago

Please notice I cannot upload previews to imgur or on github directly. Sites give errors that they do not support this file format.

adrianvanlan commented 7 years ago

It would be great if this option is available. When would it be implemented?

iho commented 7 years ago

@adrianvanlan I could be pillow error

davethecipo commented 6 years ago

It works for me. @iho did you actually create the images by calling ./manage.py generateimages?

ckcollab commented 2 years ago

I am coming from normal django ImageFields and with this setup, existing .png images don't seem to be converted with ./manage.py generateimages?

headshot_large = ProcessedImageField(
    upload_to='public/headshots', 
    storage=PublicStorage(), 
    blank=True, 
    null=True, 
    processors=[ResizeToFill(247, 422)], 
    format='WEBP', 
    options={'quality': 80}
)

All images still seem to be .pngs -- maybe I'm doing something stupid, apologies if so! Thanks for any help.

EDIT: looks like this problem isn't specific to WebP, moving to its own issue #549