Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chijete/crafyimagecompressjs
In-browser javascript image compression library (GIF, JPG, PNG, WEBP)
https://github.com/chijete/crafyimagecompressjs
gif-compression gif-compressor image-compression image-compressor image-compressor-js javascript-image
Last synced: 7 days ago
JSON representation
In-browser javascript image compression library (GIF, JPG, PNG, WEBP)
- Host: GitHub
- URL: https://github.com/chijete/crafyimagecompressjs
- Owner: chijete
- License: mit
- Created: 2024-02-03T09:50:03.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-02-05T06:26:24.000Z (9 months ago)
- Last Synced: 2024-02-05T08:23:49.638Z (9 months ago)
- Topics: gif-compression, gif-compressor, image-compression, image-compressor, image-compressor-js, javascript-image
- Language: HTML
- Homepage: https://chijete.github.io/CrafyImageCompressJS/
- Size: 65.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.
## InstallationDownload `CrafyImageCompressJS.js` and `gif.worker.js` (more info in Class Reference section).
```
```
## 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).