0.0.23 • Published 1 year ago

@appres/imgclip v0.0.23

Weekly downloads
36
License
MIT
Repository
github
Last release
1 year ago

Image Clip related functions V0.0.21

Install

npm i @appres/imgclip

Import

const ImgClip = require('@appres/imgclip');

or

import { ImgClip } from '@appres/imgclip'

Samples

Paste image

You can use image from clipboard (Ctrl+V)

ImgClip.paste((url) => {
    if(url.startsWith("blob:")) {
        ImgClip.imgurlToBase64(url).then((data) => {
            console.log("imgurlToBase64:");
            console.log(data);
            // ImgClip.revoke(url);
        });
        ImgClip.imgurlToArrayBuffer(url).then((data) => {
            console.log("imgurlToArrayBuffer:");
            console.log(data);
            // ImgClip.revoke(url);
        });
        ImgClip.imgurlToBytes(url).then((data) => {
            console.log("imgurlToBytes:");
            console.log(data);
            // ImgClip.revoke(url);
        });
        ImgClip.imgurlToReadable(url).then((data) => {
            console.log("imgurlToReadable:");
            console.log(data);
            // ImgClip.revoke(url);
        });
    }
});

Image Resize

You can make small size image (ex; thumbnail)

// 
// For Blob
// 
var image = new Image(1000, 1000);
let blobCallback = (blob) => {
    console.log("blob size:" + blob.size);
    console.log("blob type:" + blob.type);    
    blob.arrayBuffer().then(buffer => {
        let base64Img = ImgClip.bufferToBase64(buffer);
        let bytesImg = ImgClip.bufferToBytes(buffer);
    });
};
ImgClip.resize(image, { width: 200, height: 200, type: 'jpg', blobCallback: blobCallback });


// 
// For Base64
// 
var image = new Image(1000, 1000);
var base64Img = ImgClip.resize(image, { width: 200, height: 200, type: 'auto' });


// Image type :
//    'png', 'gif', 'bmp', 'jpeg', 'webp'
//     You can use 'jpg'. That will be change to 'jpeg' inside function.
//     The default is automatically set to jpg or png. 
//     It depends on the presence of an alpha channel.
0.0.20

1 year ago

0.0.21

1 year ago

0.0.22

1 year ago

0.0.23

1 year ago

0.0.18

1 year ago

0.0.15

2 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.6

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago