alexjlockwood / avocado

🥑 Vector Drawable optimization tool 🥑

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Resize vectors to a max size

PaulWoitaschek opened this issue · comments

In https://medium.com/upday-devs/optimizing-the-performance-of-vector-drawables-680a4c456286
it's recommended to only use vectors with a maximum size of 200dp.

I suggest to have an optional flag to resize the xml files to that size (maybe passing the desired max dp) while maintaining the aspect ratio.

Will consider it! Sounds like a useful feature, although I am questioning whether it is outside the scope of the project (originally avdo was basically meant to be a slimmed down version of "svgo" except for vector drawables instead... svgo does provide some disabled-by-default-plugins that are not related to optimization... things like sorting attributes, adding prefixes to class names, etc... so maybe avdo could support custom plugins like that).

At some point I want to make it possible for people to write their own custom plugins and have them be specified via command line, so I'll keep this in mind when I start thinking about how that would work!

@PaulWoitaschek did you find a way to optimize the vectors to 200dp?
the medium post is not working anymore. I am wondering if that 200dp make sense for all cases. In my case I am using a vectorDrawable as background of the root view using all the screen.

Yes, you can just manually set the width to 200dp (and adjust the height by the appropriate factor).

However if the target is actually larger than 200dp you should simply not use a vector drawable but a webp image.

But it depends on the image - if it has a large padding you should remove it from the vector and set it on the view directly and then you can continue using the vector drawable.

my target will be more than 200dp :( it is a full screen background.
I wanted to prevent using different densities like before.