1.0.4 • Published 5 years ago

fang-compressor v1.0.4

Weekly downloads
5
License
MIT
Repository
-
Last release
5 years ago

Fang Image Compressor


FIC (Fang Image Compressor) is a TypeScript Image Compressor using HTML5 Canvas that allows you to compress your jpeg & png images. (100% client-side and no extra libraries required!)

Could you imagine how much bandwidth we can save if Google, Twitter, and Facebook implement this image compression before we upload those 5MB photos? This approach will make internet faster!

Requirements or Dependencies


  • NONE

Install via NPM


    npm install fang-compressor --save-dev

Install via Yarn


    yarn add --dev fang-compressor

How it works


To compress the image, first it converts and image object to canvas and then compress it with the canvas method toDataURL(mimetype, quality)

Example


    import ImageCompressor from "fang-compressor";
    
    const compressor = new ImageCompressor();
    
    var my_img = document.getElementById("my_img");
    
    // quality ranges from 0 - 100
    var quality = 80;
    // output file format ("jpg" || "png")
    var outputFormat = "png";
1.0.4

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.3

5 years ago

1.0.0

5 years ago