A small tool to convert your app's png&jpg image files into WebP when possible
How to use
If you use Windows OS, just run the executable jar file that's inside the repo, inside "Release\WindowsOs". Then, drag the file/s&folder/s into the app, or put the paths of them into the textBox, choose the settings you wish, and press the conversion button ("do it").
If you use MacOs or Linux (which I haven't tried), here's what you should probably do:
- Install latest JDK: http://www.oracle.com/technetwork/java/javase/downloads/index.html
- Install Eclipse with Java development support: https://eclipse.org/downloads/
- Install Window-Builder: https://eclipse.org/windowbuilder/
- Download SWT (the "swt.jar" file is enough), and put it inside "external" folder: https://www.eclipse.org/swt/
- Download the converter executable file ("cwebp") and put it inside "external" folder: https://storage.googleapis.com/downloads.webmproject.org/releases/webp/index.html
- Open the project via Eclipse, make sure the "swt.jar" that you've downloaded is used. Run it via Eclipse to see that it works. If it does, you can export it as a runnable jar file and run it from outside Eclipse.
- You are good to go!
Advantages and features
- Converts png&jpg into WebP format when possible.
- Can also convert png to jpg files, if they are non-transparent (meaning not even a single pixel has a non-100%-opaque color)
- Should work on all OSs (yet tested on Windows only)
- Can handle all supported image files of all folders that are given, or only those on res/drawable and res/mipmap (which works this way by default)
- Supports drag&drop of files&folders, or entering full paths to them, separated by ";". Will handle all sub-directories, recursively.
- Supports level of encoding quality for both Jpeg and WebP
- Shows progress and summary of how many files were handled and how much space was saved.
- Native look&feel of the OS (because it uses SWT).
- Skips 9-patch images, as they aren't supported in WebP format anyway.
Disadvantages, issues, and To-do's
- Ugly UI, but still functional. I wanted to make this tool for developers anyway. I'm not as familiar with SWT as I am with Android, and I didn't want to spend too much time on it.
- Supports only png&jpg as input image files. Should be possible to handle gif files too
- Uses executable converter files instead of JNI.
- Since I'm not sure how to make the same project work well on multiple OSs (needed SWT and converter file for each), and since I don't have other OSs currently, it was only developed&tested on Windows OS.
- The tool doesn't remember which files were already handled from last time. It will go over all of them each time.
- Chosen settings aren't saved for next sessions. It also doesn't remember which files were already handled for next sessions
- Doesn't parse the gradle files. Instea, it assumes the folders structures of "res/drawable" and "res/mipmap" for the image files to handle. You can disable this check, and let it convert all supported files in all sub-directories of the given path.
- A bit slow, but this is in order to compress the files using the best space-saving algorithm.
- There should be a console/command-line tool, and not just UI-based tool.
I hope that this tool will be useful for all Android developers. I've also tried to suggest having such a tool within the IDE itself:
- cling Android-Universal-Image-Loader SlidingMenu CalendarListView PhotoView discreteSeekBar android-Ultra-Pull-To-Refresh 公共技术点之 Java 注解 Annotation DynamicLoadApk PagerSlidingTabStrip Volley android-lockpattern 公共技术点之依赖注入 ViewPagerIndicator xUtils 公共技术点之 View 事件传递 公共技术点之 Java 反射 Reflection BaseAdapterHelper 公共技术点之 Android 动画基础 Side Menu.Android Dagger CircularFloatingActionMenu HoloGraphLibrary NineOldAnimations Jave Proxy 公共技术点之 View 绘制流程 EventBus