shrinkpng
Compress the image files obtained by the front end
Last updated 3 years ago by ghkmmm .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install shrinkpng 
SYNC missed versions from official npm registry.

shrinkpng

Compress the image files obtained by the front end

???? Official website   ???? Github   ???? Npm

使用UPNG.js对 PNG 文件进行有损缩小,类似于TinyPNG和其他工具。

安装

打开终端运行下列命令:

npm install shrinkpng

yarn add shrinkpng

开始使用

请先下载本插件

然后在你的代码中引入 shrinkpng

import { shrinkImage } from "shrinkpng";

...
const _file = await shrinkImage(file, {
  quality: 80
});

Vue 文件示例

代码示例

<template>
	<div id="app">
		<input
			type="file"
			class="file"
			id="imgUpFile"
			style="position: absolute; left: 0; top: 0; width: 100%; height: 100%"
		/>
	</div>
</template>

<script>
import { shrinkImage } from "shrinkpng";

export default {
  name: "App",
  mounted() {
    document.getElementById("imgUpFile").addEventListener("change", (e) => {
      const file = e.target.files[0];
      const _file = await shrinkImage(file, {
        quality: 80
      }); // compress file
    });
  },
};
</script>

Current Tags

  • 1.2.0-beta.1                                ...           latest (3 years ago)

6 Versions

  • 1.2.0-beta.1                                ...           3 years ago
  • 1.1.2                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 1
Dependencies (3)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org | Home |