{"id":15029088,"url":"https://github.com/sunzxyong/tiny","last_synced_at":"2025-05-15T13:02:56.037Z","repository":{"id":44443480,"uuid":"87151503","full_name":"Sunzxyong/Tiny","owner":"Sunzxyong","description":"an image compression framework.（一个高保真、高压缩比的图片压缩框架）","archived":false,"fork":false,"pushed_at":"2020-10-07T10:50:31.000Z","size":66732,"stargazers_count":2629,"open_issues_count":63,"forks_count":346,"subscribers_count":70,"default_branch":"master","last_synced_at":"2025-04-07T15:04:17.083Z","etag":null,"topics":["bitmap-optimization","compress","file-compression","image-compression"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sunzxyong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-04T05:33:23.000Z","updated_at":"2025-03-25T06:28:56.000Z","dependencies_parsed_at":"2022-07-12T23:20:27.944Z","dependency_job_id":null,"html_url":"https://github.com/Sunzxyong/Tiny","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sunzxyong%2FTiny","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sunzxyong%2FTiny/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sunzxyong%2FTiny/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sunzxyong%2FTiny/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sunzxyong","download_url":"https://codeload.github.com/Sunzxyong/Tiny/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248961115,"owners_count":21189991,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitmap-optimization","compress","file-compression","image-compression"],"created_at":"2024-09-24T20:09:42.936Z","updated_at":"2025-04-14T20:55:11.745Z","avatar_url":"https://github.com/Sunzxyong.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **Tiny**\nan image compression framework.\n\n----\n\n[ ![Download](https://api.bintray.com/packages/sunzxyong/maven/Tiny/images/download.svg) ](https://bintray.com/sunzxyong/maven/Tiny/_latestVersion)[![Travis](https://img.shields.io/travis/rust-lang/rust.svg)]() [![Hex.pm](https://img.shields.io/hexpm/l/plug.svg)]() ![](https://img.shields.io/badge/architecture-clean-yellow.svg)\n\n[Blog entry with introduction](http://zhengxiaoyong.com/2017/04/23/Android%E5%9B%BE%E7%89%87%E5%8E%8B%E7%BC%A9%E6%A1%86%E6%9E%B6-Tiny/)\nor\n[Introduction of compression](http://zhengxiaoyong.com/2017/04/23/%E4%B9%9F%E8%B0%88%E5%9B%BE%E7%89%87%E5%8E%8B%E7%BC%A9/)\n\n\n## **Effect of compression**\n\n| ImageInfo | Tiny | Wechat |\n| :-: | :-: | :-: |\n6.66MB (3500x2156) | 151KB (1280x788) | 135KB (1280x788)|\n4.28MB (4160x3120) | 219KB (1280x960)| 195KB (1280x960)|\n2.60MB (4032x3024) | 193KB (1280x960)| 173KB (1280x960)|\n372KB (500x500) | 38.67KB (500x500) | 34.05KB (500x500)|\n236KB (960x1280) | 127KB (960x1280) | 118KB (960x1280)|\n\n## **Introduce**\n`Tiny` does not depend on any library , it keeps the code clean on architecture . `Tiny` also uses an asynchronous thread pool to compress images , and will hand out the result in the main thread when compression is completed.\n\n## **Usage**\n### **Installation**\n\n```\nimplementation 'com.zxy.android:tiny:1.1.0'\n```\n\n### **Choose an abi**\n**Tiny** provide abi：`armeabi`、`armeabi-v7a`、`arm64-v8a`、`x86`.\n\nChoose what you need **\"abi\"** version：\n\n```\nandroid {\n    defaultConfig {\n        ndk {\n            abiFilters 'armeabi','x86'//or armeabi-v7a、arm64-v8a、x86\n        }\n    }\n}\n```\n\n### **Initialization**\n\n```\n        Tiny.getInstance().init(this);\n```\n### **Compression**\n\n#### **AsBitmap**\n\n```\n        Tiny.BitmapCompressOptions options = new Tiny.BitmapCompressOptions();\n        //options.height = xxx;//some compression configuration.\n        Tiny.getInstance().source(\"\").asBitmap().withOptions(options).compress(new BitmapCallback() {\n            @Override\n            public void callback(boolean isSuccess, Bitmap bitmap, Throwable t) {\n                //return the compressed bitmap object\n            }\n        });\n        \n        //or sync compress.\n        BitmapResult result = Tiny.getInstance().source(\"\").asBitmap().withOptions(options).compressSync();\n```\n\n#### **AsFile**\n\n```\n        Tiny.FileCompressOptions options = new Tiny.FileCompressOptions();\n        Tiny.getInstance().source(\"\").asFile().withOptions(options).compress(new FileCallback() {\n            @Override\n            public void callback(boolean isSuccess, String outfile, Throwable t) {\n                //return the compressed file path\n            }\n        });\n        \n        //or sync compress.\n        FileResult result = Tiny.getInstance().source(\"\").asFile().withOptions(options).compressSync();\n```\n#### **AsFileWithReturnBitmap**\n\n```\n        Tiny.FileCompressOptions options = new Tiny.FileCompressOptions();\n        Tiny.getInstance().source(\"\").asFile().withOptions(options).compress(new FileWithBitmapCallback() {\n            @Override\n            public void callback(boolean isSuccess, Bitmap bitmap, String outfile, Throwable t) {\n                //return the compressed file path and bitmap object\n            }\n        });\n        \n        //or sync compress.\n        FileWithBitmapResult result = Tiny.getInstance().source(\"\").asFile().withOptions(options).compressWithReturnBitmapSync();\n```\n\n#### **BatchAsBitmap**\n\n```\n        Tiny.BitmapCompressOptions options = new Tiny.BitmapCompressOptions();\n        Tiny.getInstance().source(\"\").batchAsBitmap().withOptions(options).batchCompress(new BitmapBatchCallback() {\n            @Override\n            public void callback(boolean isSuccess, Bitmap[] bitmaps, Throwable t) {\n                //return the batch compressed bitmap object\n            }\n        });\n        \n        //or sync compress.\n        BitmapBatchResult result = Tiny.getInstance().source(\"\").batchAsBitmap().withOptions(options).batchCompressSync();\n```\n#### **BatchAsFile**\n\n```\n        Tiny.FileCompressOptions options = new Tiny.FileCompressOptions();\n        Tiny.getInstance().source(\"\").batchAsFile().withOptions(options).batchCompress(new FileBatchCallback() {\n            @Override\n            public void callback(boolean isSuccess, String[] outfile, Throwable t) {\n                //return the batch compressed file path\n            }\n        });\n        \n        //or sync compress.\n        FileBatchResult result = Tiny.getInstance().source(\"\").batchAsFile().withOptions(options).batchCompressSync();\n```\n#### **BatchAsFileWithReturnBitmap**\n\n```\n        Tiny.FileCompressOptions options = new Tiny.FileCompressOptions();\n        Tiny.getInstance().source(\"\").batchAsFile().withOptions(options).batchCompress(new FileWithBitmapBatchCallback() {\n            @Override\n            public void callback(boolean isSuccess, Bitmap[] bitmaps, String[] outfile, Throwable t) {\n                //return the batch compressed file path and bitmap object\n            }\n        });\n        \n        //or sync compress.\n        FileWithBitmapBatchResult result = Tiny.getInstance().source(\"\").batchAsFile().withOptions(options).batchCompressWithReturnBitmapResult();\n```\n\n## **Version**\n\n* **v0.0.1**：The first version.\n* **v0.0.2**：Optimize the compression strategy,and handle with the orientation of bitmap.\n* **v0.0.3**：Unified as `libtiny.so`\n* **v0.0.4**：Add cover source file configuration—see`{@link FileCompressOptions#overrideSource}`, and setting up the batch compressed file paths—see  `{@link BatchFileCompressOptions#outfiles}`\n* **v0.0.5**：Fix google store reject.\n* **v0.0.6**：Initialization is not must.Add clear compression directory method,see`{@link Tiny#clearCompressDirectory}`\n* **v0.0.7**：fix issue#29\n* **v0.1.0**：Add exception thrown interface, add the `Throwable` parameter to the callback method `{@link xxxxCallback#callback}`, see [Update Introduce](https://github.com/Sunzxyong/Tiny/issues/38)\n* **v1.0.0**：Add synchronous compression method and compression directory Settings.\n* **v1.1.0**：Add baseline setting support.\n\n## **About**\n* **Blog**：[https://zhengxiaoyong.com](https://zhengxiaoyong.com)\n* **Wechat**：\n\n![](https://raw.githubusercontent.com/Sunzxyong/ImageRepository/master/qrcode.jpg)\n\n## **License**\n\n\u003e\n\u003e     Apache License\n\u003e\n\u003e     Version 2.0, January 2004\n\u003e     http://www.apache.org/licenses/\n\u003e\n\u003e     Copyright 2018 郑晓勇\n\u003e\n\u003e  Licensed under the Apache License, Version 2.0 (the \"License\");\n\u003e  you may not use this file except in compliance with the License.\n\u003e  You may obtain a copy of the License at\n\u003e\n\u003e      http://www.apache.org/licenses/LICENSE-2.0\n\u003e\n\u003e  Unless required by applicable law or agreed to in writing, software\n\u003e  distributed under the License is distributed on an \"AS IS\" BASIS,\n\u003e  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\u003e  See the License for the specific language governing permissions and\n\u003e  limitations under the License.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunzxyong%2Ftiny","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunzxyong%2Ftiny","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunzxyong%2Ftiny/lists"}