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

jinie

v4.0.0

Published

Simple Image Editing & Compression Tool.

Downloads

125

Readme

Jinie

✨ Simple Image Editing & Compression Tool ✨

Easily enhance and optimize images before upload with Jinie. Crop, pan, scale, and rotate with a built-in compression feature to compress images to the target size. 🚀

Installation 🚀

To install the Jinie package, you can use npm:

npm install jinie

Usage 🛠️

Jinie need to be initialized only once at the top.

ReactJS example

import Jinie from 'jinie'
import 'jinie/dist/styles.css'

function App() {
  return (<div>
    {/* Initialize Jinie */}
    <Jinie />

    ..

    <BrowserRouter>
      <Routes>
        <Route .. />
        ..
      </Routes>
    </BrowserRouter>
  </div>)
}

createRoot(document.getElementById('root') as HTMLElement).render(<App />)

Here's a basic example of how to use Jinie to edit images:

import Jinie from 'jinie'

..

// Upload and crop image on init
<button
  onClick={() =>
    Jinie.init({
      accept: 'image/jpeg',
      onReady: result => {
        console.log(result) // Cropped image blob
      }
    })
  }
>
  Upload Image
</button>

// Or provide an image to crop in init
<input
  type='file'
  accept='image/jpeg'
  onChange={async (e) => {
    const img = e.target.files[0]
    Jinie.init({
      img,
      onResult: ({ code, img }) => {
        console.log(code, img)
        if (img) setImgURL(window.URL.createObjectURL(img))
      }
    })
  }}
/>

| Argument | Type | Usage | Default | | ----------- | -------- | ---------------------------------------------------- | ------------------------------------ | | onResult | Function | Result callback | | | img | ?Blob | Source image, if not provded, request image on init | | | accept | ?String | Allowed mime types, only works when img not provided | image/jpeg,image/png | | aspectRatio | ?Number | Crop box aspect ratio | | | icon | ?Number | Output png file | false | | fill | ?Number | Background color | Transparent for icon & white for jpg | | minWidth | ?Number | Min image width required else cancel | | | minHeight | ?Number | Min image height required else cancel | | | minSize | ?Number | Min image size required else cancel | | | maxSize | ?Number | Max output size | |

Result codes

| Code | Image | Note | | ----------------- | ----- | -------------------------------------------------------------- | | OK | true | Okay | | MAX_COMPRESSION | true | Image max compressed, but still greater than max size argument | | CANCELED | false | User clicked on cancel | | MIN_WIDTH_FAIL | false | Image width is less than the min image argument | | MIN_HEIGHT_FAIL | false | Image height is less than the min image argument | | MIN_SIZE_FAIL | false | Image size is less than the min size argument | | COMPRESSION_ERROR | false | Error occurred while compressing the image |

Jinie.CompressionLoop exports the Compression Loop package which is used to compress the image to the target size. It can be used alone to compress images without opening the Jinie editor.

Dark theme setup

While initializing Jinie

<Jinie theme='dark' />

or automatic theme detection with body[data-theme]="dark"

<html>
  <head>
    ..
  </head>

  <body data-theme="dark">
    ..
  </body>
</html>

License 📜

This package is open-source and available under the MIT License.

Contributing 🙌

Contributions to the Jinie package are welcome! If you have any ideas, improvements, or bug fixes, please submit a pull request or open an issue.

Authors 🖋️

Developed & maintained by neilveil