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

@zwyssigly/image-capture

v0.2.2

Published

tba

Downloads

3

Readme

WARNING

This Package is under early development and will have breaking changes and bugs !!!

Description

image-capture is a client library to process captured images before upload.

Features

  • get an image from either the file system or directly from camera
  • down scale to image to maximum width and heigth
  • crop the image to an aspect ratio with two differnt modes: contain, cover
  • rotate and flip the image before upload
  • fix orientation from exif tag before upload

Example

import { capturePicture } from '../index';

window.result = null;
window.onload = () => {
  document.getElementById("btn").onclick = () => {
    capturePicture({
      output: 'dataUrl',
      cropColor: '#FF0000',
      maxWidth: 512,
      maxHeight: 512,
      cropRatio: [1, 1],
      cropBehavior: 'contain',
      capture: 'environment',
      debug: true
    }).then(apply);
  };
  document.getElementById("cw").onclick = () => {
    window.result.rotateClockwise().then(apply);
  }
  document.getElementById("ccw").onclick = () => {
    window.result.rotateCounterClockwise().then(apply);
  }
  document.getElementById("fh").onclick = () => {
    window.result.flipHorizontally().then(apply);
  }
  document.getElementById("fv").onclick = () => {
    window.result.flipVertically().then(apply);
  }
}

function apply(result) {
  console.log(result);
  window.result = result;
  document.getElementById('img').src = result.data;
}

Methods

| Signature | Description | | ------------ | ------------ | | capturePicture(options: Options): Promise<PictureResult> | open the file dialog or camera and process the return file with the given options | | processPicture(file: Blob, options: Options): Promise<PictureResult> | in case you already got a file instance |

Options

| Option | Type | Default | Description | | ------------ | ------------ | ------------ | ------------ | | capture | false⎮'environment'⎮'user' | false | when set, it will open the camera instead of a file dialog on smart phones | | maxWidth | false⎮int | false | images is scaled down to fit within the given width | | maxHeight | false⎮int | false | images is scaled down to fit within the given height | | maxHeight | false⎮int | false | images is scaled down to fit within the given height | | orientation | 'meta'⎮1-8 | 'meta' | either get orientation from exif or uses the given orientation. (1 means no rotation or flipping) | | cropRatio | false⎮[int, int] | false | when set, it will enforce given ratio and crop the picture to fit | | cropFit | 'cover'⎮'contain' | 'cover' | defines how the images is fit into the new aspect ratio | | cropColor | string | '#000000' | defines the background color in case cropFit is set to 'contain' | | mimeType | 'keep'⎮string | 'image/jpeg' | 'keep' keeps the original format | | quality | 0-1 | 0.75 | image quality | | output | 'blob'⎮'dataUrl' | 'blob' | how the processed image is returned | | debug | bool⎮Function | false | when true logs debug information to console otherwise it will use the given Function |

PictureResult

| Signature | Description | | ------------ | ------------ | | original: Blob | original file | | data: Blob⎮string | processed image either as blob or as data url | | options: Options | options used to process the image | | rotateClockwise(): Promise<PictureResult> | processes the image again with different orientation | | rotateCounterClockwise(): Promise<PictureResult> | processes the image again with different orientation | | flipHorizontally(): Promise<PictureResult> | processes the image again with different orientation | | flipVertically(): Promise<PictureResult> | processes the image again with different orientation |