1.0.6-beta.1 • Published 3 months ago

react-native-animmated-image-resizer v1.0.6-beta.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

A simple and efficient React Native library for resizing animated and static images. This library allows you to resize images with various options, including format conversion, quality adjustments, and scaling modes. It is particularly useful for optimizing image sizes and dimensions in your React Native applications.

Supported Platforms

Animated

  • Gif to Animated Webp
  • Animated Webp to Gif

Static

  • Convert from (any of JPG, PNG, WEBP) to (any of JPG, PNG, WEBP )

Configuration

  • Dimension (Height, Width)
  • Scale mode (crop, stretch, fit)
  • Quality (0-100)

Installation

npm install react-native-image-resizer

Usage

Import

import ImageResizer, {
  resizeStaticImage, 
  resizeStaticImagesBatch, 
  resizeAnimatedImage,
} from 'react-native-animmated-image-resizer';

const {Format, Scale} = ImageResizer.getConstants();
// or use directly as ImageResizer.Format.JPEG

Constants

Format

  • ImageResizer.Format.JPEG
  • ImageResizer.Format.PNG
  • ImageResizer.Format.WEBP
  • ImageResizer.Format.AWEBP (Animated WEBP)
  • ImageResizer.Format.GIF

Scale

  • ImageResizer.Scale.CROP
  • ImageResizer.Scale.FIT_CENTER
  • ImageResizer.Scale.STRETCH

Example

Resize Animated Image

resizeAnimatedImage(imageUri, {
  height: 512,
  width: 512,
  quality: 50,
  mode: ImageResizer.Scale.FIT_CENTER,
  outFormat: ImageResizer.Format.AWEBP // or ImageResizer.Format.GIF
})
  .then(path => console.log(path)) // new file path
  .catch(error => console.log(error));

Resize Static Image

resizeStaticImage(imageUri, {
  height: 100,
  width: 100,
  quality: 70,
  mode: ImageResizer.Scale.FIT_CENTER,
  outFormat: ImageResizer.Format.WEBP
})
  .then(path => console.log(path)) // new file path
  .catch(error => console.log(error));

Resize Static Images Batch

resizeStaticImagesBatch(
  [imageUri, imageUri, imageUri, imageUri],
  {
    height: 100,
    width: 100,
    quality: 70,
    mode: ImageResizer.Scale.CROP,
    outFormat: ImageResizer.Format.PNG
  }
)
  .then(paths => console.log(paths)) // new file paths as an array
  .catch(error => console.log(error));

Supported Platforms

  • Android
  • iOS

TODO

  • Batch process Static Images
  • Batch process Animated Images
  • Upscale DownScale options
  • Background Color
  • APNG Format Support

Feel free to customize the options according to your requirements. This library aims to provide a straightforward interface for resizing images in React Native applications, with Android support marked.

1.0.6-beta.1

3 months ago

1.0.5-beta.1

3 months ago

1.0.4-beta.1

3 months ago

1.0.3-beta.1

3 months ago

1.0.1-beta.1

3 months ago

1.0.2-beta.1

3 months ago

1.0.0-beta.0

3 months ago

0.2.1

3 months ago

0.2.0

3 months ago

1.0.0-alpha.0

3 months ago

0.1.3

3 months ago

0.1.2

3 months ago

0.1.1

3 months ago

0.1.0

3 months ago