Repository: getnikola/nikola

Issue:
How could Nikola be able to process WebP format image?
I would like to use webp picture in whole site, but when I built, it reported as:

```
.  scale_images:output\images\gm-blur-shown-grid.webp
[2020-04-27T18:28:19Z] WARNING: scale_images: Can't process images\gm-blur-shown-grid.webp, using original image! (a bytes-like object is required, not 'NoneType')
[2020-04-27T18:28:19Z] WARNING: scale_images: Can't process images\gm-blur-shown-grid.webp, using original image! (a bytes-like object is required, not 'NoneType')
.  scale_images:output\images\gm-blur-shown.webp
[2020-04-27T18:28:19Z] WARNING: scale_images: Can't process images\gm-blur-shown.webp, using original image! (a bytes-like object is required, not 'NoneType')
[2020-04-27T18:28:19Z] WARNING: scale_images: Can't process images\gm-blur-shown.webp, using original image! (a bytes-like object is required, not 'NoneType')
```

There were raw webp pictures in my `output` directory, but there won't generate thumbnails.

And then, I search in conf.py, Google and GitHub issue, but didn't find any description to enable this feature.
Is there any way to use webp in nikola site?
How could Nikola be able to process WebP format image?
I would like to use webp picture in whole site, but when I built, it reported as:

```
.  scale_images:output\images\gm-blur-shown-grid.webp
[2020-04-27T18:28:19Z] WARNING: scale_images: Can't process images\gm-blur-shown-grid.webp, using original image! (a bytes-like object is required, not 'NoneType')
[2020-04-27T18:28:19Z] WARNING: scale_images: Can't process images\gm-blur-shown-grid.webp, using original image! (a bytes-like object is required, not 'NoneType')
.  scale_images:output\images\gm-blur-shown.webp
[2020-04-27T18:28:19Z] WARNING: scale_images: Can't process images\gm-blur-shown.webp, using original image! (a bytes-like object is required, not 'NoneType')
[2020-04-27T18:28:19Z] WARNING: scale_images: Can't process images\gm-blur-shown.webp, using original image! (a bytes-like object is required, not 'NoneType')
```

There were raw webp pictures in my `output` directory, but there won't generate thumbnails.

And then, I search in conf.py, Google and GitHub issue, but didn't find any description to enable this feature.
Is there any way to use webp in nikola site?


Discussion:

Resolving patch:
diff --git a/nikola/image_processing.py b/nikola/image_processing.py
--- a/nikola/image_processing.py
+++ b/nikola/image_processing.py
@@ -43,7 +43,7 @@
 class ImageProcessor(object):
     """Apply image operations."""
 
-    image_ext_list_builtin = ['.jpg', '.png', '.jpeg', '.gif', '.svg', '.svgz', '.bmp', '.tiff']
+    image_ext_list_builtin = ['.jpg', '.png', '.jpeg', '.gif', '.svg', '.svgz', '.bmp', '.tiff', '.webp']
 
     def _fill_exif_tag_names(self):
         """Connect EXIF tag names to numeric values."""
@@ -146,6 +146,10 @@ def resize_image(self, src, dst=None, max_size=None, bigger_panoramas=True, pres
                     size = min(w, max_size * 4), min(w, max_size * 4)
             try:
                 im.thumbnail(size, Image.ANTIALIAS)
+                save_args = {}
+                if icc_profile:
+                    save_args['icc_profile'] = icc_profile
+
                 if exif is not None and preserve_exif_data:
                     # Put right size in EXIF data
                     w, h = im.size
@@ -156,9 +160,9 @@ def resize_image(self, src, dst=None, max_size=None, bigger_panoramas=True, pres
                         exif["Exif"][piexif.ExifIFD.PixelXDimension] = w
                         exif["Exif"][piexif.ExifIFD.PixelYDimension] = h
                     # Filter EXIF data as required
-                    im.save(dst, exif=piexif.dump(exif), icc_profile=icc_profile)
-                else:
-                    im.save(dst, icc_profile=icc_profile)
+                    save_args['exif'] = piexif.dump(exif)
+
+                im.save(dst, **save_args)
             except Exception as e:
                 self.logger.warning("Can't process {0}, using original "
                                     "image! ({1})".format(src, e))


Test patch: