Ajatt-Tools / PasteImagesAsWebP

🍙 An Anki add-on that makes your images small.
https://ankiweb.net/shared/info/1151815987
GNU Affero General Public License v3.0
24 stars 6 forks source link

bulk downscale in Webp format [feature request] #12

Closed cocowash closed 2 years ago

cocowash commented 2 years ago

I want to downscale some pictures to save some extra space. The issue that I have is that I already converted all my media to Webp. The size of the picture doesn't changes with a bulk convert since its already Webp. Could it be possible to add an option on settings to bulk edit size on Webp images? Ty in advance.

tatsumoto-ren commented 2 years ago

You can do it with a bash loop instead, which is faster and should solve your issue.

cd -- ~/.local/share/Anki2/user/collection.media
for file in ./*.webp; do
    cwebp "$file" -o "$file" -resize 0 200 -q 33
done

Adjust -resize and -q to your liking.

cocowash commented 2 years ago

I have high respect for people who know how to program or use a terminal to solve issues. The problem is that I don't have right now the time to learn how to use it, so for me an addon that can do that for me is better suited.
ty for the response.

tatsumoto-ren commented 2 years ago

You don't have to learn how to use the terminal, but you can try the snippet I've posted above to quickly fix your media collection. I hope it helps.

In regards to the feature allowing to reconvert existing webp images, I think that's it's not something a large number of people need, but if I have free time I might add it to the add-on.

tatsumoto-ren commented 2 years ago

Should work now. Please test.

cocowash commented 2 years ago

Should work now. Please test.

I tried again and now the plug-in can process webp but I have noticed that once the plugin makes a downscale it ignore that image in further actions: Lets suppose that I have a 800x800 image and I chose to downscale it to 400x400 to 72 dpi. At first it works well, but if I try for example to change that image to 200x200 and 50 dpi the addon does not make any changes.
Nontheless is a great progress that now the addon can downscale webp files, ty.

tatsumoto-ren commented 2 years ago

but if I try for example to change that image to 200x200 and 50 dpi the addon does not make any changes.

Sometimes the Anki browser overwrites the modifications and you have to try again. I don't know how to prevent that yet.