1.0.0 • Published 4 months ago

my-image-helper v1.0.0

Weekly downloads
-
License
-
Repository
-
Last release
4 months ago

My Image Helper Library

A simple and easy-to-use image helper library for React Native using Expo's expo-image-picker and expo-image-manipulator. This library provides utilities for picking images from the device, manipulating them (resize, crop, rotate, etc.), and applying filters.

Installation

To install the library, run the following command in your React Native project:

npm install my-image-helper-library



1. Picking an Image
import { pickImage } from 'my-image-helper-library';

const pickImageFromGallery = async () => {
  const imageUri = await pickImage(false); // Truyền false để chọn từ thư viện ảnh
  console.log(imageUri);
};

const pickImageFromCamera = async () => {
  const imageUri = await pickImage(true); // Truyền true để chọn từ camera
  console.log(imageUri);
};

2. Manipulating Image (Resize, Crop, Rotate)
import { manipulateImage } from 'my-image-helper-library';

const manipulateImageExample = async (uri) => {
  const manipulatedUri = await manipulateImage(uri, {
    resize: { width: 300, height: 300 }, // Resize to 300x300
    rotate: 90, // Rotate by 90 degrees
  });

  console.log(manipulatedUri);
};
3. Adjusting Image Properties (Brightness, Contrast, Saturation)
import { adjustImage } from 'my-image-helper-library';

const adjustImageExample = async (uri) => {
  const adjustedUri = await adjustImage(uri, {
    brightness: 0.5,  // Adjust brightness
    contrast: 1.2,    // Adjust contrast
    saturation: 0.8,  // Adjust saturation
  });

  console.log(adjustedUri);
};
4. Applying Filters (Sepia, Grayscale, Invert)
import { applyFilter } from 'my-image-helper-library';

const applyFilterExample = async (uri) => {
  const filteredUri = await applyFilter(uri, 'sepia'); // Apply sepia filter
  console.log(filteredUri);
};