Coder Social home page Coder Social logo

chijete / crafyimagecompressjs Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 67 KB

In-browser javascript image compression library (GIF, JPG, PNG, WEBP)

Home Page: https://chijete.github.io/CrafyImageCompressJS/

License: MIT License

HTML 100.00%
gif-compression gif-compressor image-compression image-compressor image-compressor-js javascript-image

crafyimagecompressjs's Introduction

CrafyImageCompressJS

In-browser javascript image compression and resizing library with support for static images (JPG, PNG, WEBP) and animated GIFs, with and without transparency.

  • Resize image with maximum width and maximum height.
  • Compress image quality to reduce size.

Principal class CrafyImageCompressJS it's inside CrafyImageCompressJS.js file.

Installation

Download CrafyImageCompressJS.js and gif.worker.js (more info in Class Reference section).

  <script src="./CrafyImageCompressJS.js"></script>

Class Reference

Create new instance of class.

  new CrafyImageCompressJS(image, image_type)
Parameter Type Description
image blob Required. Image Blob (PNG, JPG, WEBP, GIF)
image_type string Required. Image mime type (example: "image/png")
gifjs_workerScript_url string Optional. gif.js workerScript URL (link to gif.worker.js file)

Returns: true.

Compress the image.

  compressImage(quality, maxWidth, maxHeight)
Parameter Type Description
quality float Required. Target quality from 0 to 1 (0 is lower quality and 1 is better quality, example: 0.6).
maxWidth float Optional. Result image maximum width in pixels.
maxHeight float Optional. Result image maximum height in pixels.
maxWidthForGIF float Optional. Result image maximum width in pixels (only for GIFs).
maxHeightForGIF float Optional. Result image maximum height in pixels (only for GIFs).

Returns: Blob Image ("image/gif" for GIF input, "image/webp" for everyone else).

crafyimagecompressjs's People

Contributors

chijete avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.