jekyll-webp icon indicating copy to clipboard operation
jekyll-webp copied to clipboard

Fails to convert GIFs

Open AleksandrHovhannisyan opened this issue 5 years ago • 4 comments

Steps to reproduce:

  1. Create a GIF in a directory currently being processed by the gem.
  2. Add ".gif" to the list of file formats.
  3. Specify ."gif" as the gif extension.
  4. Observe the following error:
 Conversion for image someImage.gif failed, no webp version could be created for this image

Here's my config:

webp:
  enabled: true
  
  # The quality of the webp conversion 0 to 100 (where 100 is least lossy)
  quality: 75

  # List of directories containing images to optimize, nested directories will only be checked if `nested` is true
  # By default the generator will search for a folder called `/img` under the site root and process all jpg, png and tiff image files found there.
  img_dir: ["/assets/img/"]

  # Whether to search in nested directories or not
  nested: true

  # add ".gif" to the format list to generate webp for animated gifs as well
  formats: [".jpg", ".png", ".gif"]

  # File extensions for animated gif files 
  gifs: [".gif"]

  # Set to true to always regenerate existing webp files
  regenerate: true

  # Local path to the WebP utilities to use (relative or absolute)
  # Omit or leave as nil to use the utilities shipped with the gem, override only to use your local install
  webp_path: nil

All other file formats work.

AleksandrHovhannisyan avatar Jul 04 '20 13:07 AleksandrHovhannisyan

Did you ever figure this out? I'm having the same issue.

N-Upchurch avatar Jun 18 '21 23:06 N-Upchurch

@N-Upchurch Nope, I didn't

AleksandrHovhannisyan avatar Jun 18 '21 23:06 AleksandrHovhannisyan

So, it looks like you have to use gif2webp to convert gifs, not cwebp. At least, when I download the binaries and test, the latter works whereas the former does not.

I've submitted a pull request to fix this as best as I can. It's most definitely not the best way to do it, but I'm not a Ruby dev haha. Only tested on Ubuntu. In the meantime, if anyone needs to use the gif -> webp functionality, they can manually edit their local copy of the gem using the updated files in my fork, and adding the gif2webp binaries.

N-Upchurch avatar Jun 19 '21 02:06 N-Upchurch

Yeah, I just process images manually on my site and use gif2webp for animated GIFs

But I think the latest version of this plugin should be able to handle GIFs (haven't tested)

AleksandrHovhannisyan avatar Jun 19 '21 15:06 AleksandrHovhannisyan