Skip to content

This is a Client of the acrool-imgz api server, which can isolate its core from the impact of the environment version.

License

Notifications You must be signed in to change notification settings

acrool/acrool-imgz-client

Repository files navigation

Acrool Imgz Client

Acrool Imgz Client Logo

This is a Client of the acrool-imgz api server, which can isolate its core from the impact of the environment version.

NPM npm npm

npm downloads npm

Features

Installation

yarn add @acrool/imgz-client

Examples

use in your nodejs code:

import {ImgzNodeClient} from '@acrool/imgz-client';

const imgzClient = new ImgzNodeClient('http://localhost:8081');

const options = {
    resize: {width: 500},
    quality: 90,
};
const thumbOptions = {
    resize: {width: 100},
    quality: 80,
};
await imgzClient
    .squashWebp(filePath)
    .toSave(uploadIOThumbPath, thumbOptions)
    .toSave(uploadIOPath, options)
    .completeAll();

use in your browser frontend code:

import {ImgzClient} from '@acrool/imgz-client';
import {SubmitHandler, useForm} from 'react-hook-form';

interface IForm {
    sourceFile: File
}

const Example = () => {
    const HookForm = useForm<{sourceFile}>();
    
    const handleSubmitHandler: SubmitHandler<IForm> = async formData => {
        const imgzClient = new ImgzClient();
    
        const options = {
            resize: {width: 250},
            quality: 90,
            timeout: 10000,  // Example timeout
        };
        await imgzClient
            .squashWebp(formData.sourceFile[0], options)
            .then(setBlobImg);
    
    };
}

License

MIT © Acrool & Imagine

About

This is a Client of the acrool-imgz api server, which can isolate its core from the impact of the environment version.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published