All Projects → Hu12037102 → ImageCompress

Hu12037102 / ImageCompress

Licence: other
一个超级强大的一行代码图片压缩工具,支持多个压缩、单个压缩、压缩后的bitmap

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to ImageCompress

ZipArchive
A single-class pure VB6 library for zip with ASM speed
Stars: ✭ 38 (-47.95%)
Mutual labels:  compress
QArchive
Async C++ Cross-Platform library that modernizes libarchive using Qt5 🚀. Simply extracts 7z 🍔, Tarballs 🎱 and other supported formats by libarchive. ❤️
Stars: ✭ 66 (-9.59%)
Mutual labels:  compress
photo-magician
🎨 provide some common image process apis with canvas
Stars: ✭ 12 (-83.56%)
Mutual labels:  compress
slimarray
SlimArray compresses uint32 into several bits, by using a polynomial to describe overall trend of an array.
Stars: ✭ 39 (-46.58%)
Mutual labels:  compress
VIDEOconvertor
A stable and Fast telegram video convertor bot which can encode into different libs and resolution, compress videos, convert video into audio and other video formats, rename with thumbnail support, generate screenshot and trim videos.
Stars: ✭ 180 (+146.58%)
Mutual labels:  compress
react-native-compress-image
compress image with react native
Stars: ✭ 22 (-69.86%)
Mutual labels:  compress
Tiny
Blog:https://zhengxiaoyong.com Wechat:
Stars: ✭ 2,505 (+3331.51%)
Mutual labels:  compress
http compression
🗜️ Deno HTTP compression middleware
Stars: ✭ 34 (-53.42%)
Mutual labels:  compress
minifier
Middleware to minify Html, CSS and Javascript responses
Stars: ✭ 15 (-79.45%)
Mutual labels:  compress
CodeProject
Common code for unity project develop.
Stars: ✭ 28 (-61.64%)
Mutual labels:  compress
xcompress
XCompress is a free file archiver utility on Linux, providing multi-format archiving to and extracting from ZIP, Z, GZIP, BZIP2, LZ, XZ, LZMA, 7ZIP, TAR, RAR and ZSTD.
Stars: ✭ 65 (-10.96%)
Mutual labels:  compress
ti.imagefactory
The ImageFactory Module for Appcelerator Titanium
Stars: ✭ 68 (-6.85%)
Mutual labels:  compress
pyas2-lib
AS2 Library for building and parsing Messages and MDNs
Stars: ✭ 33 (-54.79%)
Mutual labels:  compress
web-dist
传统模式开发的web站点 进行整站所有文件压缩及混淆处理
Stars: ✭ 43 (-41.1%)
Mutual labels:  compress
imgZip
js压缩图片,转blod流.上传
Stars: ✭ 25 (-65.75%)
Mutual labels:  compress
RecordVideo
视频录制压缩
Stars: ✭ 47 (-35.62%)
Mutual labels:  compress
LaraOutPress
This is simply compress your final out of Larvel Application and serve to the browser.
Stars: ✭ 56 (-23.29%)
Mutual labels:  compress
image-compressor
Frontend javascript module for resizing and compressing images
Stars: ✭ 41 (-43.84%)
Mutual labels:  compress
compress-pdf-tg-bot
A Telegram bot can compress the size of PDF documents. Useful for digital documentations.
Stars: ✭ 24 (-67.12%)
Mutual labels:  compress
tinypng-free
Use the upload api of tinypng's homeage to compress images
Stars: ✭ 29 (-60.27%)
Mutual labels:  compress

ImageCompress

由于公司项目APP对图片的处理较多,刚开始上手,到处OOM,实在让人脑壳疼!项目迭代到今天有10个月吧!对图片处理也有一些深刻的理解!看了市面上的传统压缩方法!压缩质量虽然可以,但是有些图片失真严重。故此,写一个图片压缩框架,供大家参考,欢迎提意见!

运行效果预览

压缩运行效果预览

多图压缩预览

animation

压缩图片大小预览

animation

使用方法(很简单:简直能用一行代码解决)

拓展性强:
1、可以自定义压缩图片的宽高(默认:1280*720);
2、默认压缩大小为150kb(可以根据自己需求设置),超过150kb压缩,小于不压缩;
3、一行代码解决。

依赖方法

1、 gradle依赖:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.Hu12037102:ImageCompress:2.3.0'
}

/**
 *压缩一张图片
 * @param imageConfig   bean
 * @param onImageResult file回调数据
 */
 CompressImageTask.get().compressImage(SingChoiceImageActivity.this,ImageConfig.getDefaultConfig(mImageFile.getAbsolutePath()), new CompressImageTask.OnImageResult() {
                        @Override
                         public void startCompress() {
                               //压缩前可以选择加载LoadingView
                         }
                        @Override
                        public void resultFileSucceed(File file) {
                             //成功回调
                        }

                        @Override
                        public void resultFileError() {
                          //失败回调
                        }
                    });
/**
 *压缩多张图片(集合)
 * @param list  图片集合
 * @param onImagesResult  file集合回调数据
 */
 CompressImageTask.get().compressImages(MultipleChoiceImageActivity.this, data, new CompressImageTask.OnImagesResult() {
                    @Override
                     public void startCompress() {
                                 //压缩前可以选择加载LoadingView
                           }
                     @Override
                     public void resultFilesSucceed(List<File> fileList) {
                         //成功回调
                     }

                     @Override
                     public void resultFilesError() {
                         //失败回调
                     }
                 });
        
/**
 *压缩生成bitmap
 * @param imageConfig  bean
 * @param onBitmapResult  bitmap结果回调
 */
  CompressImageTask.get()
  .compressBitmap(MultipleChoiceImageActivity.this,ImageConfig.getDefaultConfig(mImageFile.getAbsolutePath()), new CompressImageTask.OnBitmapResult() {
             @Override
              public void startCompress() {
               //压缩前可以选择加载LoadingView
              }
           @Override
           public void resultBitmapSucceed(Bitmap bitmap) {//结果成功回调

           }

           @Override
           public void resultBitmapError() {//结果失败回调

           }
       });

       public class ImageConfig {
           /**
            * 压缩默认宽为720px
            */
           public int compressWidth = 720;
           /**
            * 压缩默认长为1280px
            */
           public int compressHeight = 1280;
           public String imagePath;


           public ImageConfig(String imagePath) {
               this.imagePath = imagePath;
           }

           public ImageConfig() {
           }

           /**
            * 图片格式
            */
           public Bitmap.CompressFormat format = Bitmap.CompressFormat.JPEG;

           /**
            * 图片质量
            */
           public Bitmap.Config config = Bitmap.Config.ARGB_8888;


           /**
            * 默认缓存的目录
            */
           public String cachePathDirectory = FileUtils.FILE_DIRECTOR_NAME;

           /**
            * 默认的缓存图片名字
            */
           public String imageName = "/hxb_" + String.valueOf(System.currentTimeMillis()) + UUID.randomUUID().toString().replaceAll("-", "").trim() + ".jpg";

           public int compressSize = CompressPicker.COMPRESS_SIZE;


               /**
                * 调用默认压缩的图片配置属性
                */
                   public static ImageConfig getDefaultConfig(String filePath){
                       return new ImageConfig(filePath);
                   }

       }
}

###代码混淆 -keep public class utils.bean.**{*;}

联系方式

QQ:1069305953
邮箱:[email protected]
微博:Mr_胡小白二胡

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].