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

chilled-lemon

v0.0.6

Published

This library is used to read the PNG Info values of images generated by Stable Diffusion web UI.

Downloads

14

Readme

Test

This library provides functionality to extract information stored within PNG images generated by Stable Diffusion Web UI.

It also provides functions to mutually convert between infotext and JSON formats.

Usage(extract infotext in PNG images)

You can use getInfotext or getInfotextJson to extract infotext embedded in PNG images.

Support CJS/ESM/UMD

CommonJS

const { getInfotext, getInfotextJson } = require('chilled-lemon');
const { readFile } = require('node:fs/promises');

(async () => {
    const buf = await readFile('./test.png');

    const infotext = await getInfotext(buf);
    console.log(infotext);

    const json = await getInfotextJson(buf);
    console.log(json);
})();

ES Modules

import { getInfotext, getInfotextJson } from 'chilled-lemon';
import { readFile } from 'node:fs/promises';

const buf = await readFile('./test.png');

const infotext = await getInfotext(buf);
console.log(infotext);

const json = await getInfotextJson(buf);
console.log(json);

UMD

<!DOCTYPE html>
<html>

<head>
    <script src="/node_modules/chilled-lemon/dist/index.umd.js"></script>
</head>

<body>
    <input type="file" id="inputFile" />
    <button onclick="getPngInfoFromFile()">Get PNG Info</button>
    <pre id="output"></pre>

    <script>
        const { getInfotext, getInfotextJson } = window.ChilledLemon;

        async function getPngInfoFromFile() {
            const fileInput = document.getElementById('inputFile');
            const file = fileInput.files[0];
            const arrayBuffer = await file.arrayBuffer();

            try {
                const outputElement = document.getElementById('output');

                const infotext = await getInfotext(arrayBuffer);
                outputElement.textContent += '\n\n===PNG INFO (infotext format)===\n' + infotext;

                const json = await getInfotextJson(arrayBuffer);
                outputElement.textContent += '\n\n===PNG INFO (JSON format)===\n' + JSON.stringify(json);
            } catch (err) {
                console.error(`Error reading file: ${err.message}`);
            }
        }
    </script>
</body>

</html>

Usage (Conversion between infotext and JSON)

You can use convertInfotextToJson and convertJsonToInfotext to convert between infotext and JSON.

import { getInfotext, getInfotextJson, convertInfotextToJson, convertJsonToInfotext } from 'chilled-lemon';
import { readFile } from 'node:fs/promises';

const buf = await readFile('./test.png');

const infotext = await getInfotext(buf);
const convertedJson = await convertInfotextToJson(infotext);
console.log(convertedJson)

const json = await getInfotextJson(buf);
const convertedInfotext = await convertJsonToInfotext(json);
console.log(convertedInfotext);

Development

Code formatter

We are currently utilizing "deno fmt" as our code formatter. In order to use this, developers will need to have Deno installed on their PC.

At the moment, I am the sole developer working on this project, which is why I chose "deno fmt".
it allows for easy code formatting without the necessity to include dependent packages in the project.

In the future, should we expand our team and if other developers express a preference for a different formatter, I am open to discussions and would appreciate if the suggestions are raised as issues for consideration.

inspired

The idea for this source code was inspired by this blog post (Japanese post).

License

MIT