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 🙏

© 2025 – Pkg Stats / Ryan Hefner

jaw-mk-utils

v1.0.6

Published

Drawing and image scaling utils for the JAW Motions pose estimation and joint angle calculator API

Downloads

8

Readme

MK-utils

Drawing and image scaling utils for the JAW Motions pose estimation and joint angle calculator API.

The API is available here: JAW pose estimation and angle calculator

Installing


Using npm:

$ npm install jaw-mk-utils

Using yarn:

$ yarn add jaw-mk-utils

Using jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/jaw-mk-utils@1.0.6/utils.js"></script>

Using unkpkg CDN:

<script src="https://unpkg.com/jaw-mk-utils@1.0.6/utils.js"></script>

Utilities


Scaling images:

The scaleImage() method allow to scale an image to the specified width in pixels. The height of the image scales automatically. It takes the following arguments:

| Argument | Description | |----------|---------------------------| | img | Image object | | width | Width in pixels to scale |

import MK from 'jaw-mk-utils'

const scaledImage = MK.scaleImage(img, 600)

Drawing results:

The drawOutput() method allows to draw the obtained landmarks over a canvas. It takes the folowing arguments:

| Argument | Description | |----------|-------------------------------------------------------------------| | Results | Array of landmarks detected from the API. Required. | | canvasId | Id of the canvas object where the output will be drawn. Required. | | options | Object with optional configurations. Optional. |

import MK from 'jaw-mk-utils'

MK.drawOutput(landmarks, 'output-canvas')

The possible options that the options argument can take are listed below:

| Option | Description | Default | |-----------------|--------------------------------------------------------------------------------|---------| | connectorColor | String. Color of the lines that will be drawn between the detected points. | #00FF00 | | landmarksColor | String. Color of the detected points. | #FF0000 | | projectionColor | String. Color of the calculated points and projected lines that will be drawn. | #0000FF | | connectorWidth | Number. Width of the lines that will be drawn between the detected points. | 2 | | landmarksWidth | Number. Size of the detected points. | 1 |

Usage example


The following block of code shows an usage example using axios to get the data from the API:

const getData = (url, plane)=> {
    // An image object is created and it's src is setted to the url argument
    const img = new Image()
    img.src = url

    img.onload = ()=> {
        // After the img is setted, we'll create an scaled version of the image
        const scaledImage = MK.scaleImage(img, 600)

        // We select the canvas and set it's width and height to the width and height of the scaled image
        const canvas = document.getElementById('result-canvas')
        const ctx = canvas.getContext('2d')
        canvas.width = scaledImage.width
        canvas.height = scaledImage.height

        // We draw the image on the canvas
        ctx.drawImage(img, 0, 0, canvas.width, canvas.height)

        // And then we make a request to the API, drawing the response over the previous canvas
        let data = { url, plane }

        let options = {
            connectorColor: '#fff'
        }

        axios
            .post('[path-to-api]', data)
            .then((response)=> {
                MK.drawOutput(response.data.landmarks, 'result-canvas', options)
            })
            .catch((error)=> {
                console.log(error)
            })

    }

    
}

// We have a button that starts the request
const btn = document.getElementById('btn')
btn.addEventListener('click', ()=> {

    // We get the image file and the plane from the inputs
    const fileInput = document.getElementById('file')
    const plane = document.getElementById('plane').value

    if(fileInput.files.length === 0) return

    // And then, we read the image as a DataURL, passing that url and plane to the getData() functions
    const reader = new FileReader()
    reader.onload = ()=> {
        getData(reader.result, plane)
    }

    reader.readAsDataURL(fileInput.files[0])

})