# Luban **Repository Path**: qs_os/Luban ## Basic Information - **Project Name**: Luban - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2021-04-18 - **Last Updated**: 2021-04-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Luban Luban:An image compressing tool for OHOS with efficiency very close to that of WeChat Moments. This module helps to compress images of type : png, jpg, bitmap and gif. Installation tutorial 1.For using Luban module in sample app,include the below library dependency to generate hap/luban.har: Modify entry build.gradle as below : ``` dependencies { implementation project(path: ':library') } ``` 2.For using Luban in separate application make sure to add the luban.har in entry libs folder. Modify entry build.gradle as below : ``` dependencies { implementation fileTree(dir: 'libs', include: ['*.har']) } ``` Usage Instructions 1. A sample project which provides runnable code examples that demonstrate uses of the classes in this project is available in the entity/ folder. 2. Luban internally uses the IO thread to perform image compression, implementations only need to specify what happens when the process finishes successfully. ``` Luban.with(this) .setTargetDir(/*PATH*/) // pass target data directory path .ignoreBy(/*SIZE*/) // pass least compress size .load(/*FILE*/) // pass image to be compressed .setCompressListener(new OnCompressListener() { // Set up return @Override public void onStart() { // TODO Called when compression starts, display loading UI here } @Override public void onSuccess(File file) { // TODO Called when compression finishes successfully, provides compressed image } @Override public void onError(Throwable throwable) { // TODO Called if an error has been encountered while compressing } }).launch(); // Start compression ``` Limitations: Compression of .tif or .tiff is not supported. # License Copyright 2016 Zheng Zibin ``` Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ```