Android Image Processing API to edit photo programmatically. This library is used by react-native-photo-manipulator.
Add dependency in module build.gradle
repositories {
mavenCentral()
}
dependencies {
implementation 'com.guhungry.android:photo-manipulator:1.0.2'
}Import using
import com.guhungry.photomanipulator.BitmapUtils
Get width and height of image in CGSize
| NAME | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| image | Bitmap | Yes | Source image |
Crop image from specified cropRegion
| NAME | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| image | Bitmap | Yes | Source image to be crop and resize |
| cropRegion | CGRect | Yes | Region to be crop in CGRect(x, y, size, width) |
| outOptions | BitmapFactory.Options | Yes | Configuration for decode and encode result bitmap |
Crop and resize image from specified cropRegion into targetSize using resize mode cover
| NAME | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| image | Bitmap | Yes | Source image to be crop and resize |
| cropRegion | CGRect | Yes | Region to be crop in CGRect(x, y, size, width) |
| targetSize | CGSize | Yes | Size of result image |
| outOptions | BitmapFactory.Options | Yes | Configuration for decode and encode result bitmap |
| matrix | Matrix | No | Orientation transform matrix from getCorrectOrientationMatrix() |
Print text into image
| NAME | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| image | Bitmap | Yes | Source image to be crop and resize |
| text | String | Yes | Text to print in image |
| position | PointF | Yes | Position to in in x, y |
| color | Int | Yes | Text color |
| textSize | Float | Yes | Text size |
| font | Typeface | No | Font use to print. Default = App's Default Font |
| alignment | Paint.Align | No | Text alignment (left, right and center). Default = left |
| thickness | Float | No | Outline of text. Default = 0 |
| rotation | Float | No | Rotation angle in degrees. Default = 0 |
Overlay image on top of background image
| NAME | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| background | Bitmap | Yes | Background image |
| overlay | Bitmap | Yes | Overlay image |
| position | PointF | Yes | Position of overlay image in background image |
Flip the image horizontally, vertically or both
| NAME | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| image | Bitmap | Yes | The image to be flipped |
| mode | FlipMode | Yes | Flip mode .Horizontal, .Vertical or .Both |
Rotate the image 90°, 180° or 270°
| NAME | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| image | Bitmap | Yes | The image to be rotated |
| mode | RotationMode | Yes | Rotation mode .R90 (90° Clockwise), .R180 (180° Half Rotation) or .R270 (270° Clockwise, aka 90° Counterclockwise) |
Get corrected transform matrix for orientation data in EXIF
| NAME | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| image | InputStream | Yes | Image input stream |
Import using
import com.guhungry.photomanipulator.FileUtils
Create temp file into cache directory with a prefix
| NAME | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| context | Context | Yes | Android context |
| prefix | String | Yes | Temp file name prefix |
| mimeType | String | Yes | Mime type of image. Default = image/jpeg |
Get cache path of app
| NAME | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| context | Context | Yes | Android context |
Delete all files in directory with prefix
| NAME | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| directory | File | Yes | Path to clean |
| prefix | String | Yes | File name prefix to match |
Open file from uri as input stream
| NAME | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| context | File | Yes | Path to clean |
| uri | String | Yes | Uri of image can be remote (https?://) or local (file://, android.res:// and content://) |
Import using
import com.guhungry.photomanipulator.MimeUtils
Get image file extension from mimeType (Support .jpg, .png and .webp)
| NAME | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| mimeType | String | Yes | Image mime type |
Get image Bitmap.CompressFormat from mimeType (Support .jpg, .png and .webp)
| NAME | TYPE | REQUIRED | DESCRIPTION |
|---|---|---|---|
| mimeType | String | Yes | Image mime type |