Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zouhir/lqip
Low Quality Image Placeholders (LQIP) Module for Node
https://github.com/zouhir/lqip
Last synced: 14 days ago
JSON representation
Low Quality Image Placeholders (LQIP) Module for Node
- Host: GitHub
- URL: https://github.com/zouhir/lqip
- Owner: zouhir
- Created: 2017-06-24T10:17:56.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-02-11T00:20:26.000Z (almost 3 years ago)
- Last Synced: 2024-10-19T22:35:14.413Z (23 days ago)
- Language: JavaScript
- Size: 1.39 MB
- Stars: 433
- Watchers: 7
- Forks: 30
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
LQIP: Low Quality Images Placeholder
```
npm install --save lqip
```
Generating Base64 from an image:
```js
const lqip = require('lqip');const file = `./dest/to/file/zouhir-riding-a-bike.jpg`;
lqip.base64(file).then(res => {
console.log(res); // "data:image/jpeg;base64,/9j/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhY.....
});```
Generating colour palette from an image:
```js
const lqip = require('lqip');const file = `./dest/to/file/zouhir-riding-a-bike.jpg`;
lqip.palette(file).then(res => {
// the response will be sorted from most dominant colour to least
console.log(res); // [ '#628792', '#bed4d5', '#5d4340', '#ba454d', '#c5dce4', '#551f24' ]
});```
##### `lqip.base64(filePath: string)`
This method accepts an image file path, the file has to be one of those formats ['jpeg', 'jpg', 'png'] and returns a Base64
image string with a valid format and ready to be used in web applications such as in tags source or in CSS properties URLs.##### `lqip.palette(filePath: string)`
This method accepts an image file path, and returns an colour palette as an array of HEX colour values. The array that is returned
is sorted from the most to the least dominant colour.
- [Medium web app](https://medium.com/cucumbertown-magazine/the-beginners-guide-to-composition-in-food-photography-how-to-transform-your-food-photos-from-good-39613ab78bf2)
- [Instagram native mobile app](https://www.instagram.com/)
- [Polymer shop project](https://shop.polymer-project.org/)
- Essential Image Optimization, An eBook by Addy Osmani [link](https://images.guide/)
Related projects to this would be [lqip-loader for webpack](https://github.com/zouhir/lqip-loader) as well as [lqip-cli](https://github.com/zouhir/lqip-cli).
Thanks to contributors and [Colin van Eenige](https://twitter.com/cvaneenige) for his reviews and early testing.
MIT - [Zouhir Chahoud](https://zouhir.org/)