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

js-image-clipper

v1.0.0

Published

A JavaScript image clipping plug-in

Downloads

6

Readme

install

npm install js-image-clipper --save
In browser
<script src="../dist/jsImageClipper.js"></script>
<link rel="stylesheet" href="../dist/jsImageClipper.css" type="text/css" />
javascript
import JsImageClipper from 'js-image-Clipper';
import 'imageclipper/dist/jsImageClipper.css';
<body>
	<input type="file" accept="image/*" id="file" />
	<div class="clipperContainer" style="width:200px;height:200px;"></div>
</body>
<script>
document.querySelector("#file").addEventListener("change",fileChange);
function fileChange(e){
    var file=e.target.files[0];
    var url=URL.createObjectURL(file);
    var selector='.clipperContainer';//container for plug-ins,a string class name or id name
    var path=url;//image Path type can be URL.createObjectURL or dataURL or string
    var options={clipperBoxWidth:200,clipperBoxHeight:200,onImageLoaded:imgLoadedHandler}
    JsImageClipper.init(selector,path,options)
    function imgLoadedHandler(){
        console.info(“image has loaded");
    }
    JsImageClipper.getImgBlob(function(blob){
        //get Image blob
    })
    var baseData=JsImageClipper.getImgDataURL('image/png',1);//get image data URL(base64)
    
}
</script>
OPTIONS

| key | defaultValue | | | ---------------- | ------------ | ------------------------------------------------------ | | clipperBoxWidth | 200 | The width of the clipping block | | clipperBoxHeight | 200 | The height of the clipping block | | onImageLoaded | undefined | A callback function is called when the image is loaded |

INTERFACE
1 JsImageClipper.init(selector,path,option);/*Initialization function,Display the clipping surface in the specified 															container.selector:a string class name or id name path:the image's path can be 													URL.createObjectURL or dataURL or string*/
2 JsImageClipper.getIsLoaded();/*A Boolean value that represents whether the image has been loaded*/
3 JsImageClipper.zoomIn();//zoom in the image
4 JsImageClipper.zoomOut();//zoom out the image
5 JsImageClipper.getClipperPosition;//get the object for crop image data
6 JsImageClipper.getImgDataURL(type,encoderOptions);/*return the crop image dataURL,type:A DOMString indicating the image 															format.The default format type is image/png. encoderOptions:A Number between 													0 and 1 indicating the image quality to use for image formats*/
7 JsImageClipper.getImgBlob(callback, type, encoderOptions);/*The method creates a Blob object representing the image. 			                                                               callback:A callback function with the resulting Blob object as a                                                                single argument.type(Optional):A DOMString indicating the image                                                                  format. The default type is image/png. encoderOptions(Optional):A                                                                Number between 0 and 1 indicating image quality if the requested                                                                type is image/jpeg or image/webp. If this argument is anything                                                                 else, the default values 0.92 and 0.80 are used for image/jpeg and                                                               image/webp respectively. Other arguments are ignored.*/
8 JsImageClipper.destory();