Skip to content

Commit

Permalink
Notes on manual conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
jissereitsma authored Feb 7, 2024
1 parent fc479d3 commit 1467501
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,37 @@ Ask your system administrator to install this library. Or ask the system adminis
#### Can I use this with Amasty Shopby?
Yes, you can. Make sure to install the addition https://github.com/yireo/Yireo_Webp2ForAmastyShopby as well.

#### How can I convert WebP images manually from the CLI?
Even though this extension (or actually its parent extension `Yireo_NextGenImages`) support a CLI (`bin/magento next-gen-images:convert`), using this extension for 1000s of images will definitely not be performant. If you want to convert all images at once from the CLI, it is better to look at other tools. For instance, the `cwebp` binary (part of the Google WebP project itself) could be installed. Or perhaps you could use `convert` of the Imagick project.

Next, a simple shell script could be used to build all WebP files:
```bash
find . -type f -name \*.jpg | while read IMAGE do; convert $IMAGE ${IMAGE/.jpg/.webp}; done
```

Or another example (of @rostilos):
```bash
#!/bin/bash
start=`date +%s`
directory="../pub/media"

cd "$directory" || exit
find . -type f \( -iname \*.jpg -o -iname \*.jpeg -o -iname \*.png \) -print0 |

while IFS= read -r -d $'\0' file;
do
filename=$(basename -- "$file")
new_filename="${filename%.*}.webp"
new_filepath="$(dirname "$file")/$new_filename"
echo "Converting: $file -> $new_filepath"
cwebp -q 80 -quiet "$file" -o "$new_filepath"
done
end=`date +%s`
runtime=$((end-start))

echo "Execution completed in $runtime seconds."
```

## Requesting support

### First check to see if our extension is doing its job
Expand Down

0 comments on commit 1467501

Please sign in to comment.