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

ccimg

v1.0.1

Published

A set of web image tools by js, include Compress, Watermark

Downloads

2

Readme

Demo预览

http://palxp.com/ccimg/

安装说明

下载本项目,将dist文件下的 js 引入页面

<script data-main="../js/main" src="../js/lib/require.js"></script>

使用到图片裁剪工具时需引入 css

<link rel="stylesheet" type="text/css" href="../css/cropper.css" />

npm引入方式

npm install ccimg

web项目中使用,目前只支持压缩和水印功能:

var ccimg = require('ccimg')
ccimg.compress // 使用等于下面的 $compress
ccimg.watermark // 使用等于下面的 $watermark

使用说明

1. 图片裁剪

传入参数:

src: 图片地址

aspectRatio: 裁剪框比例,不传为自由变换 eg: 16/9 4/3 2/3 1/1

示例:

$cropper(src).open({
	aspectRatio: 1,
	ok: function (base64) {
	  // 确认回调函数,返回裁剪后图片。
	},
	toBlob: function (blob) {
	  // 确认回调函数,返回裁剪后图片,转换成用于传输到后台的格式,使用formData接收。
	  // var formData = new FormData();
	  // formData.append('croppedImage', blob);
	}
})

2. 图片压缩

传入参数:

src:(string/array) 单个图片地址,或者多个图片地址的数组

width / height:(number) 自定义压缩后宽高,可不传

quality:(1~99) 压缩质量 数值越大质量越高

original: (boolean) 传true压缩后分辨率接近或与原始分辨率一致

$compress({
    src: document.getElementById('xxx').src,
    width: 100, 
    height: 100,
    quality: 40,
    ok: function (base64) {
        // 返回的压缩图片,如果传递数组则返回数组:
        // base64.forEach(function (item) {})
    },
    toBlob: function (blob) {
    	// 返回转换为blob的格式
    }
})

3. 图片底部加水印

传入参数:

src: 图片地址

text: 水印文字

fontSize: 字体大小,不传或者为0则自适应

var src = document.getElementById('xxx').src
$watermark(src).add({
    text: '文字',
    fontSize: 18,
    ok: function (base64) {
        // 完成后回调函数
    }
})