@simpleimg/decode-blurhash
v1.0.11
Published
This module transform blurhash string into base64 image, making it possible to use blurhash as a placeholder for images easily.
Downloads
50
Readme
Simple Image Cloud - Blurhash Decoder
This module transform blurhash string into base64 image, making it possible to use blurhash as a placeholder for images easily.
Install
yarn add @simpleimg/decode-blurhash
or
npm install @simpleimg/decode-blurhash
Documentation
You can find the documentation for the Decode Blurhash here.
Quick Usage - React
import decode from '@simpleimg/decode-blurhash';
import {
useEffect,
useState
} from 'react';
export default () => {
const [
background,
setBackground
] = useState('');
/* will generate a base 64 encoded image with 32px by 32px */
useEffect(() => {
setBackground(decode('LGF5]+Yk^6#M@-5c,1J5@[or[Q6.'));
}, []);
/* then use it with background-image and background-size: cover */
return (
<div style={{
backgroundImage: `url(${background})`,
backgroundSize: 'cover',
width: 400,
height: 400
}}/>
);
};
Feedback
We want to hear your issue reports and feature requests at [email protected]