npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

readyimage

v0.0.2

Published

ReadyImage

Downloads

1

Readme

readyImage

Load and Optimize Photos in the Browser

ReadyImage is a promise-based image resizer / optimizer. ReadyImage uses and requires blueimp's loadImage library. Photo orientation is corrected automatically. Optionally the photo can be resized to a max width/height and max quality. Photos can also be optionally cropped from the center/center as a square at the maximum width and quality.

The optimized / resized image data is returned in the promise as a data URL (base64 encoded image). The data can be applied as the source of an image to be displayed in the browser, or sent over the network to be saved for use later.

Adding ReadyImage to your Project

On the Web via jsdelivr CDN

// blueimp's loadImage library
<script src="https://cdn.jsdelivr.net/npm/blueimp-load-image/js/load-image.all.min.js">

// readyImage
<script src="https://cdn.jsdelivr.net/npm/readyimage/readyimage.min.js">

Options

  • maxWidth (integer. Defaults to 1024)
  • maxHeight (integer)
  • quality (decimal percentage. Default to 1.0)
  • type (file type. Defaults to "jpeg")
  • crop (boolean. Defaults false)

Using readyImage

Example: readyImage accepts the files inputted by the user into a file input.

// Create a file input and drop in on the page
var fileInput = document.createElement('input');
fileInput.type = "file";
document.body.prepend(fileInput);

// Create an image element and drop it on the page
var image = document.createElement('img');
document.body.appendChild(image);

// readyImage options
var options = {
  "maxWidth":800,
  "maxHeight":800,
  "quality": 0.50,
  "type":"jpeg",
  "crop": false
};

// When user changes or selects a file with the file input...
fileInput.onchange = () => {

  // If they selected a file...
  if (fileInput.files[0]) {

    // ready the image...
    readyImage(fileInput.files[0],options).then(result=>{

      // The image is ready. Display it in the image element.
      console.log('image ready!');
      image.src = result;

    }).catch(err => {

      // The user selected a file that is not supported as an image...
      console.log(err);

    });
  } else {

    // The user did not select any image or file... (hit cancel perhaps...)
    console.log('No image selected.');
  }
};