-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Ankiweb comment:
ever since Anki 2.1 (and long ago on Droid/iOS) WEBP has been supported, which offers vastly superior compression both lossy over JPEG and lossless over PNG.
Follow up:
Anki pasted image filetype settings
Anki has a setting in Preferences for pasting from clipboard as a .png. It's off by default. If it is on everything pastes as a .png, otherwise everything pastes as a .jpg. See _processImage in Anki's anki/qt/aqt/editor.py
Can a pasted image maintain its file type?
Maybe monkey patch _processImage in anki/qt/aqt/editor.py to maintain the original image type? This could go hand in hand with #2 customizing an image name.
It's not obvious how to get the type, but it's worth a dive...
Can ImageResizer offer the option of .webp?
Using wrap now, it seems to be trying to paste a .webp file, but nothing ends up pasted. It may be that Qt requires the Qt5-image-formats-plugins. I installed with apt but no change. Maybe it isn't being found and I need a path change. But even if that works, is it a feasible option for the add-on? No.
But I don't understand why I would need it because I have saved a .webp file via pasting, without ImageResizer turned on. It seems that either the plugin is necessary to manipulate a .webp file or I'm doing it wrong... If I can get it working with the plugin that would settle it. Or if I could find something speaking to this point in the Qt documentation. Until then it could just be that I'm doing it wrong.
OR! Or there's a "bug" in Anki. I shouldn't have been able to paste a .webp image that stays a .webp image at all, it should have converted to either .jpg or .png on paste depending on my settings. That means .webp files aren't going through the same branch of the code. (It turns out this is also true for gifs. It also turns out the names aren't recreated using a hash for these two file types.) Maybe it's by design, maybe not... WAIT. If it's not going through that branch of the code then my changing a string value in that branch shouldn't have any effect... this is odd. Why is it that using ImageResizer causes those formats to go down a different branch?
Image quality value
Anki specifies an image's quality value (out of a possible 1 to 100) as 50 for .png and 80 for .jpg. Should this value be tinkered with?
In a simple trial, upping that value to 100 didn't make a significant difference in image quality. But that was in the specific case of converting from .webp to .png and .jpg. In the case of .png it made the file 20% bigger.
It's worth exploring if it makes a difference when maintaining the image filetype. ie. .jpg resized to a .jpg. Though the expectation is it would be a trade off with file size.
How do the other image resizing add-ons do it? Do they maintain file size and/or quality?
-
Resize images in the editor
-
Max image height in editor
-
CSS
Working Conclusion of .webp
It's worth exploring, for both image quality and file size reasons. Resizing a large .webp file to a small (as in space on the screen) .png file actually increased the file size while the quality of the image tanked. I'm trying to baseline this with a .webp resized to a smaller (as in space on the screen) .webp but haven't been able to make it work yet.
Research here and elsewhere seems to show that it generally uses smaller file sizes for comparable image quality.
A MAJOR drawback is that it can't be rendered on any Apple OS and as far as I know there's no decent way around that because they force WebKit on everything. So Anki iOS and AnkiWeb on any Apple device whether Safari or not. There seem to be some workarounds available, but they all come with baggage and have no official support... .webp is not a general solution, maybe a non-default niche option for some but probably not worth a lot of trouble at the moment.
Relevant docs
-
Qt5 : Qt Image Formats - does not include
.webpin the list of formats supported without plugins
Other
- Repo for a Qt webp plugin - source for a Qt < 5.3 plugin for
.webpthat tipped me onto the Qt image-formats-plugin