ankidroid / Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.
GNU General Public License v3.0
8.7k stars 2.24k forks source link

Investigate conversion of hard-to-replace PNGs to SVG #8741

Open mikehardy opened 3 years ago

mikehardy commented 3 years ago

Almost all graphics in the app are SVG instead of PNG now. There are just a few left that are hard to convert. It may be that some or all of these are impossible to convert, that is unknown and part of the task.

It is certain that this is not a high priority though, as the number of remaining PNGs is so small that any additional compiled app size benefits will be very small.

ankidroid_txt (I have svg format of anki txt if someone wants to try ) drawer_shadow.9 widget_bg_number.9.png widget_bg_small_finish.png widget_bg_small.png widget_bg_time.9.png

Originally posted by @vinishhub in https://github.com/ankidroid/Anki-Android/issues/8707#issuecomment-828659145

@vinishhub - please attach your SVG of ankidroid_txt here if you could? Thank you!

vinishhub commented 3 years ago

@mikehardy github does not support svg format can i add drive link

david-allison commented 3 years ago

@mikehardy github does not support svg format can i add drive link

You can add it to a zip and upload it

vinishhub commented 3 years ago

ankidroid_txt ->ankidroid_text.zip

vinishhub commented 3 years ago

@mikehardy what if we convert these images to webp ?

mikehardy commented 3 years ago

I don't know if that is a big enough difference in compression to matter. I also don't know if webp is supported down to api21 on all devices in all the places?

vinishhub commented 3 years ago

webp is supported down to api21

https://developer.android.com/guide/topics/media/media-formats#image-formats When I tried converting widget_bg_small.png this was the result๐Ÿ‘‡๐Ÿผ๐Ÿ‘‡๐Ÿผ image

mikehardy commented 3 years ago

Hmm - that has potential and there are definitely some cases that just can't go svg. If webp works for them, it's worth a try. These are very small savings though, so I would not spend more than a few minutes on it :-)

vinishhub commented 3 years ago

Hmm - that has potential and there are definitely some cases that just can't go svg. If webp works for them, it's worth a try. These are very small savings though, so I would not spend more than a few minutes on it :-)

one more thing is that we can't convert 9-patch files to Webp

github-actions[bot] commented 3 years ago

Hello ๐Ÿ‘‹, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

Ghanem21 commented 2 years ago

Hi can I work on this issue as I'm new and want to be accepted in Gsoc, what i have understood that there is some PNGs I have to make them SVGs and then replace them from drawable file

Am I right?

mikehardy commented 2 years ago

@Ghanem21 :wave: - I had to learn about 9-patch files just now in order to even answer your question - these are worth a read: https://stackoverflow.com/questions/17124719/creating-using-9-patch-images-in-android https://tekeye.uk/android/examples/ui/android-9-patch-image-files

The short answer to this:

what i have understood that there is some PNGs I have to make them SVGs and then replace them from drawable file?

Is this from the description:

It may be that some or all of these are impossible to convert, that is unknown and part of the task.

In other words, I don't know. It appears that webp could maybe work for non-9-patch files, as our minSdkVersion is 21. But for each of the 9-patch files you would need to examine their specific use and see if the special feature of 9-patch - that it is stretchable but with specific stretch and non-stretch areas - is actual a strict requirement for the image. If 9-patch's stretch/non-stretch feature is a requirement for the image, it is impossible to convert the image I think.

Ghanem21 commented 2 years ago

@mikehardy okay, then you want me to try change it to 9-Patch or webp depend on it's support 9-patch or not am I right?

mikehardy commented 2 years ago

That's not what I said, I believe my comment - after re-reading it - is the full description of the task.

Ghanem21 commented 2 years ago

I don't know if webp is supported down to api21 on all devices in all the places , I think we can make it patch-9 and let non Patch-9 as png or try to make it from scratch as svg

@mikehardy

I try to make this patch-9 on ankidroid_txt and this is screen in android studio

Screenshot 2022-04-05 231543

mikehardy commented 2 years ago

I don't know if webp is supported down to api21 on all devices in all the places

Documentation seems to indicate it's supported fine: https://developer.android.com/studio/write/convert-webp

mikehardy commented 2 years ago

I am most interested in an inventory of the 3 patch-9 images that checks to see whether they actually need to be patch-9 (with it's strech/non-stretch area feature) or not.

Ghanem21 commented 2 years ago

I tried to make it with widgit_small_small and that what I get is that what are you expected?

Screenshot 2022-04-06 030705

Ghanem21 commented 2 years ago

also I try to convert patch-9 to webp but it is not supported if there is simple png copy we can make it webp easily

Ghanem21 commented 2 years ago

Have I continue in that or try to find another way?

mikehardy commented 2 years ago

I feel like you are trying technical things without stepping back and thinking about value of the things being done. It's not just a "do this" task, it's a "we need information so we can make decisions task"

This has not been addressed from above:

I am most interested in an inventory of the 3 patch-9 images that checks to see whether they actually need to be patch-9 (with it's strech/non-stretch area feature) or not.

That has nothing to do with trying other things, it's a gather information and give opinions problem.

Ghanem21 commented 2 years ago

The 9-Patch is a modified PNG image that allows Android to determine how the image can be stretched to meet the specific layout during runtime

Three are some Common Usege -

  1. Button backgrounds
  2. Page backgrounds.
  3. Splash screens.

we will think about them while we try to make our decicons

ankidroid_txt: => easily to convert to svg,webp and patch-9 it is used in launch_screen and tv_banner .xml in launch_screen it is used as windowBackground so it's not scratched while the runtime but making it svg or webp will be better than patch-9

drawer_shadow.9: it's already in patch-9 form in the app it wont change it's size during the runtime but it's so bad that we can't make it webp

widget_by_number.9: it is so important to be patch-9(as in the project) as we use it as textView background which will scretch during the runtime (This is the ideal format for it I think)

widget_by_small and widget_by_small_finish: are both related to each other as they are use in widget_small and there visibility get changed during runtime it prefered to be in svg ,webp ,patch-9 that better than png to much but the star will be diffcult in patch-9 only we can select the whole star or make it webp or svg

so I hope now you can make your descion but try to take them as individuals

TanmayAgarwal123 commented 1 year ago

I would love to work on this project, can you assign me Regards, Tanmay Agarwal

dae commented 1 year ago

How are we at in 2023?