https://github.com/jzbrooks/vgo
vector graphic optimization
https://github.com/jzbrooks/vgo
Last synced: 24 days ago
JSON representation
vector graphic optimization
- Host: GitHub
- URL: https://github.com/jzbrooks/vgo
- Owner: jzbrooks
- License: mit
- Created: 2019-08-25T23:48:16.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-09-18T18:54:01.000Z (about 2 months ago)
- Last Synced: 2025-09-18T21:39:56.118Z (about 2 months ago)
- Language: Kotlin
- Homepage:
- Size: 78.5 MB
- Stars: 50
- Watchers: 3
- Forks: 2
- Open Issues: 23
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
- trackawesomelist - jzbrooks/vgo (⭐39) - vgo is a tool for optimizing and converting between vector artwork representations. (Recently Updated / [Oct 01, 2024](/content/2024/10/01/README.md))
README
## vgo
[](https://github.com/jzbrooks/vgo/actions/workflows/build.yml)
[](https://ossindex.sonatype.org/component/pkg:maven/com.jzbrooks/vgo)
[](https://ossindex.sonatype.org/component/pkg:maven/com.jzbrooks/vgo-core)
[](https://ossindex.sonatype.org/component/pkg:maven/com.jzbrooks/vgo-plugin)
vgo optimizes vector graphics through a format-agnostic approach by leveraging vgo-core's intermediate representation.
It can convert between common vector formats, including SVG, Android Vector Drawables, and Jetpack Compose ImageVector _and_ optimize them to boot.
## Installation
#### Homebrew
`brew install jzbrooks/repo/vgo`
#### Manually
Download the distribution from the release page and ensure it has execute permission. On macOS & Linux run `chmod u+x vgo`.
vgo requires Java 17.
## Gradle Plugin
The plugin aims to be fast and small by leveraging (for the entire tool) the JVM your Gradle build is already using.
The `shrinkVectorArtwork` task is added to your project on plugin application.
To incorporate the plugin in your build, configure maven central plugin resolution:
```groovy
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
}
```
Then, in the relevant project, add the plugin.
> [!NOTE]
> You must have the android tools sdk on your build classpath if you are converting SVGs to vector drawables.
> This is typically done by applying the Android Gradle Plugin.
> You must have the kotlin compiler on your build classpath if you are using the `ImageVector` format.
> This is typically done by applying the Kotlin Gradle Plugin.
```groovy
plugins {
id 'com.jzbrooks.vgo'
}
// Default configuration shown
vgo {
inputs = fileTree(projectDir) {
include '**/res/drawable*/*.xml'
}
outputs = inputs
showStatistics = true
format = OutputFormat.UNCHANGED
noOptimization = false
indent = 0
}
```
> [!TIP]
> For Android projects a non-zero indent is better for readability and provides no apk size impact after AAPT processing.
## Command Line Interface
```
> vgo [options] [file/directory]
Options:
-h --help print this message
-o --output file or directory, if not provided the input will be overwritten
-s --stats print statistics on processed files to standard out
-v --version print the version number
--indent [value] write files with value columns of indentation
--format [value] output format (svg, vd, iv)
--no-optimiation skip graphic optimization
```
> `java -jar vgo` for Windows
## Examples
### CLI
```
# Optimize files specified from standard in
> find ./**/ic_*.xml | vgo
# Optimize vector.xml and overwrite its contents
> vgo vector.xml
# Optimize vector.xml and write the result into new_vector.xml
> vgo vector.xml -o new_vector.xml
# Optimize multiple input sources write results to the
> vgo vector.xml -o new_vector.xml ./assets -o ./new_assets
```
### Gradle Plugin
```kotlin
// Optimize and convert svgs to vector drawables at build time
vgo {
format = OutputFormat.VECTOR_DRAWABLE
outputs = files(project.fileTree(project.projectDir) {
include("icons/**/*.svg")
}.map {
val file = file("src/main/res/drawable/${it.nameWithoutExtension}.xml")
file.parentFile?.mkdirs()
file.createNewFile()
file
}).asFileTree
}
tasks.getByName("processDebugResources").configureEach {
dependsOn("shrinkVectorArtwork")
}
```
## Build instructions
This project uses the Gradle build system.
To build the binary: `./gradlew binary`
To run the tests: `./gradlew check`
To see all available tasks: `./gradlew tasks`