Commit 613f2b7f authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

optimization_advice.md: Improve vector drawable and pngquant parts

Change-Id: I293c4ea85a90edbfcb28cbcf7bd3f1201550f3ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1902912Reviewed-by: default avatarMohamed Heikal <mheikal@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713462}
parent 40b14f8c
...@@ -36,17 +36,25 @@ ...@@ -36,17 +36,25 @@
## Optimizing Images ## Optimizing Images
* Would a vector image work? * Would a vector image work?
* Images that can be described by a series of paths should generally be
stored as vectors.
* The one exception is if the image will be used pre-Lollipop in a
notification or application icon.
* For images used in native code: [VectorIcon](https://chromium.googlesource.com/chromium/src/+/HEAD/components/vector_icons/README.md). * For images used in native code: [VectorIcon](https://chromium.googlesource.com/chromium/src/+/HEAD/components/vector_icons/README.md).
* For Android drawables: [VectorDrawable](https://codereview.chromium.org/2857893003/). * For Android drawables: [VectorDrawable](https://developer.android.com/guide/topics/graphics/vector-drawable-resources).
* Convert from `.svg` online using https://inloop.github.io/svg2android/.
* Optimize vector drawables with [avocado](https://bugs.chromium.org/p/chromium/issues/detail?id=982302). * Optimize vector drawables with [avocado](https://bugs.chromium.org/p/chromium/issues/detail?id=982302).
* (Googlers): Find most icons as .svg at [go/icons](https://goto.google.com/icons).
* Would **lossy** compression make sense (often true for large images)? * Would **lossy** compression make sense (often true for large images)?
* If so, [use lossy webp](https://codereview.chromium.org/2615243002/). * If so, [use lossy webp](https://codereview.chromium.org/2615243002/).
* And omit some densities (e.g. add only an xxhdpi version). * And omit some densities (e.g. add only an xxhdpi version).
* Would **near-lossless** compression make sense? * For lossless `.png` images, see how few unique colors you can use without a
* This can often reduce size by >50% without a perceptible difference. noticeable difference.
* [Use pngquant](https://pngquant.org) to try this out (use one of the GUI * This can often reduce an already optimized .png by 33%-50%.
tools to compare before/after). * [Use pngquant](https://pngquant.org) to try this out.
* Are the **lossless** images fully optimized? * Requires trial and error for each number of unique colors.
* Use one of the GUI tools linked from the website to do this easily.
* Finally - Ensure .png files are fully optimized.
* Use [tools/resources/optimize-png-files.sh](https://cs.chromium.org/chromium/src/tools/resources/optimize-png-files.sh). * Use [tools/resources/optimize-png-files.sh](https://cs.chromium.org/chromium/src/tools/resources/optimize-png-files.sh).
* There is some [Googler-specific guidance](https://goto.google.com/clank/engineering/best-practices/adding-image-assets) as well. * There is some [Googler-specific guidance](https://goto.google.com/clank/engineering/best-practices/adding-image-assets) as well.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment