libpixel.js
libpixel.js allows developers to use the services of LibPixel in their web applications without having to rely on other dependencies. The service allows you to generate and sign URLs.
Introduction
With the help of libpixel.js
you can generate responsive images by defining the paremeters and letting the library generate the signed URLs. The generated and signed URLs can be used by setting the src
attribute of the img
element. picture
element can be used to create a more responsive system that loads specific images according to the resolution and orientation of devices.
Install
There are two ways to install libpixel.js
:
1: npm: $ npm install libpixel
2: Manually: Download the latest release and use the JavaScript files in the src
folder.
Usage
libpixel.js
is pretty simple to get started with. You just start by requiring the module and creating an instance of the client. The only required attribute is host
, which should contain your LibPixel domain
that you will setup while signing up.
In addition to host
, the following attributes are supported:
secret
: Auth secret for your LibPixel account. Required for signing requests.https
: Generate HTTPS URLs. Default isfalse
.
After initializing the LibPixel client, you are ready to start using libpixel.js
. With the help of it, you can sign existing URLs to enable LibPixel support by using the sign()
method, or you can generate and sign new URLs at the same time by using the url()
method of the LibPixel client.
Regardless of what method you use, the output will be a signed URL, which can then use in the src
attribute of your img
elements to provide processed images that meet your requirements.
Sign URLs
You can sign an existing URL using the sign()
method:
Generate URLs
You can also generate and sign URLs at the same time with the url()
method:
License
libpixel.js
is owned by LibPixel and is licensed under the MIT license. Contributions are welcomed.
Last updated