All Projects → ghnor → Flora

ghnor / Flora

Licence: mit
可能是Android平台上最快的图片压缩框架。

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Flora

Imgp
📸 High-performance cli batch image resizer and rotator
Stars: ✭ 744 (+365%)
Mutual labels:  image-compression
Emage
🧙‍♂️ From developers to developers: a cross-platform tool for losslessly image compression.
Stars: ✭ 99 (-38.12%)
Mutual labels:  image-compression
Lerc
Limited Error Raster Compression
Stars: ✭ 126 (-21.25%)
Mutual labels:  image-compression
Compression Tools
A Docker image that contains a set of tools for compressing and optimize images in many formats with high results, it also includes GNU Parallel
Stars: ✭ 15 (-90.62%)
Mutual labels:  image-compression
Advancedluban
An Advanced Compress Image Library for Android / 高效、简洁的图片压缩工具库
Stars: ✭ 1,284 (+702.5%)
Mutual labels:  image-compression
Imagine
🖼️ PNG/JPEG optimization app for macOS, Windows and Linux.
Stars: ✭ 1,859 (+1061.88%)
Mutual labels:  image-compression
Caesium Image Compressor
Caesium is a cross-platform image compression software aimed at helping photographers, bloggers, webmasters, businesses or casual users at storing, sending and sharing digital pictures. Based on libcaesium.
Stars: ✭ 595 (+271.88%)
Mutual labels:  image-compression
Waifu2x Extension
Image, GIF and Video enlarger/upscaler achieved with waifu2x and Anime4K. [NO LONGER UPDATED]
Stars: ✭ 149 (-6.87%)
Mutual labels:  image-compression
Tinify Python
Python client for the Tinify API.
Stars: ✭ 95 (-40.62%)
Mutual labels:  image-compression
Img2ktx
Converts common image formats (PNG, JPG, etc.) to GPU-native compressed (BCn, ETC, ASTC) in KTX containers.
Stars: ✭ 117 (-26.87%)
Mutual labels:  image-compression
Image Resizer
On-the-fly image resizing using Node.js and libvips. Heroku Ready!
Stars: ✭ 59 (-63.12%)
Mutual labels:  image-compression
Bamboo
A cross-platform TinyPNG client 🌱🎍
Stars: ✭ 80 (-50%)
Mutual labels:  image-compression
Fuif
Free Universal Image Format
Stars: ✭ 115 (-28.12%)
Mutual labels:  image-compression
Image Actions
A Github Action that automatically compresses JPEGs, PNGs and WebPs in Pull Requests.
Stars: ✭ 844 (+427.5%)
Mutual labels:  image-compression
Pngcrush
It is a free, open source command-line utility for optimizing PNG image files ( batch script included ).
Stars: ✭ 136 (-15%)
Mutual labels:  image-compression
Imgbot
An Azure Function solution to crawl through all of your image files in GitHub and losslessly compress them. This will make the file size go down, but leave the dimensions and quality untouched. Once it's done, ImgBot will open a pull request for you to review and merge. [email protected]
Stars: ✭ 732 (+357.5%)
Mutual labels:  image-compression
Tinify Java
Java client for the Tinify API.
Stars: ✭ 107 (-33.12%)
Mutual labels:  image-compression
Caesium Clt
Caesium Command Line Tools - Lossy/lossless image compression tool using mozjpeg and zopflipng
Stars: ✭ 149 (-6.87%)
Mutual labels:  image-compression
Optimize Images
A command-line interface (CLI) utility written in pure Python to help you reduce the file size of images.
Stars: ✭ 141 (-11.87%)
Mutual labels:  image-compression
Pictureselector
Picture Selector Library for Android or 图片选择器
Stars: ✭ 11,095 (+6834.38%)
Mutual labels:  image-compression

Flora

可能是Android平台上最快的图片压缩框架。

依赖

dependencies {
	...
	
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.ghnor:flora:1.0.0-alpha1'
}

用法用例

  • 异步压缩:
Flora.with().load(source...).compress(new Callback<>());
  • 同步压缩:
Flora.with().load(R.drawable.test2).compressSync();

可控的压缩任务

Flora.with(Activity)
Flora.with(FragmentActivity)
Flora.with(Fragment)
Flora.with(SupportFragment)
// 上面的四类,会自动在页面生命周期结束后,终止压缩任务。

// 通过TAG标志位来结束一系列的任务。
Flora.with(TAG)
// 强制结束任务。
Flora.cancel(TAG);

// 无参,此时的任务进行其实是不受控的,强烈建议不要采用这种写法。
Flora.with() 

更多属性

Flora.with()
        // 配置inSample和quality的算法,内置了一套基于Luban的压缩算法
        .calculation(new Calculation() {
            @Override
            public int calculateInSampleSize(int srcWidth, int srcHeight) {
                return super.calculateInSampleSize(srcWidth, srcHeight);
            }

            @Override
            public int calculateQuality(int srcWidth, int srcHeight, int targetWidth, int targetHeight) {
                return super.calculateQuality(srcWidth, srcHeight, targetWidth, targetHeight);
            }
        })
        // 对压缩后的图片做个性化地处理,如:添加水印
        .addDecoration(new Decoration() {
            @Override
            public Bitmap onDraw(Bitmap bitmap) {
                return super.onDraw(bitmap);
            }
        })
        // 配置Bitmap的色彩格式
        .bitmapConfig(Bitmap.Config.RGB_565)
        // 最大文件尺寸,不建议配置此项,目前采用的方式是重复写入文件,判断大小,比较耗时
        .maxFileSize(1.0)
        // 同时可进行的最大压缩任务数量
        .compressTaskNum(1)
        // 安全内存,设置为2,表示此次压缩任务需要的内存小于1/2可用内存才进行压缩任务
        .safeMemory(2)
        // 压缩完成的图片在磁盘的存储目录
        .diskDirectory(File)
        .load(source...)
        .compress();

其他

  • 压缩速度

本身内部采用线程池的方案去进行压缩任务,同时进行了必要的内存检查。

在不会OOM的前提下,最大的提升了压缩的速度,常见的9图大小在20M+能够在2s内处理完成。

当然,机器性能,系统当时的内存都是对此产生影响,我的测试机是【魅蓝Note】...

  • 压缩效果

由于压缩策略集成自Luban,所以最后图片压缩大小前后对比可以参考Luban。

我在此基础上,对社交产品中常见的长图的需求进行了一定的优化。

License

MIT License

Copyright (c) 2017 ghnor

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].