django-imagekit icon indicating copy to clipboard operation
django-imagekit copied to clipboard

Webp

Open iho opened this issue 8 years ago • 8 comments

Hi Does not work with format='WEBP'

How to fix it?

iho avatar May 25 '17 18:05 iho

In [3]: from PIL import features
   ...: print (features.check_module('webp'))
True


iho avatar May 25 '17 18:05 iho

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

vstoykov avatar May 26 '17 06:05 vstoykov

@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 avatar May 26 '17 08:05 iho

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

iho avatar May 26 '17 08:05 iho

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

adrianvanlan avatar Jun 16 '17 13:06 adrianvanlan

@adrianvanlan I could be pillow error

iho avatar Jun 16 '17 13:06 iho

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

davethecipo avatar Mar 03 '18 15:03 davethecipo

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

ckcollab avatar Mar 28 '22 00:03 ckcollab