We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 122339d commit ab9f6b3Copy full SHA for ab9f6b3
imgwebpconverter.py
@@ -22,9 +22,14 @@ def convert_to_webp(path, quality):
22
print(f'Skipping {image_path}, WebP version already exists.')
23
continue # Skip to the next file
24
25
- # Save the image in WebP format with the specified quality
26
- img.save(webp_path, 'webp', quality=quality)
27
- os.remove(image_path)
+ try:
+ # Save the image in WebP format with the specified quality
+ img.save(webp_path, 'webp', quality=quality)
28
+ os.remove(image_path)
29
+ except Exception as e:
30
+ print(f'Error converting {image_path} to WebP: {e}')
31
+ continue
32
+
33
print(f'Converted: {image_path} -> {webp_path}')
34
35
if __name__ == "__main__":
0 commit comments