AJPEG (Alpha-JPEG)
PNG File size can be a hassle. This library provides transparency support to JPEG images allowing you to get lightweight images and speed up your page load.
AJPEG GULP
encoder allows you to split PNG file into 2 separate files :
- a JPEG file without transparency that you can compress
- a PNG file containing the alpha channel only
The decoder loads the 2 files and fast restore the alpha channel using native html canvas
composite operation.
Original 88ko | Compressed 19ko | Alpha 9ko |
Demo
https://mbossan.github.io/AJPEG/
Install
$ npm install --save-dev ajpeg
Graphics Magick
Make sure GraphicsMagick is installed on your system and properly set up in your PATH
.
- Mac OS X (using Homebrew):
brew install graphicsmagick
- Ubuntu:
apt-get install graphicsmagick
Encoding
const gulp = ajpeg = ; gulp;
API
ajpeg([quality])
Type: number
Default: 60
JPEG compression from 1 to 100
Decoding
Setup
Include the library
OR
const AJPEG = ;
Usage
Load into a Canvas
;
Load into an Image
;
Autoload via html attribute parsing
License
MIT ©