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

vue3-image-slim

v1.0.6

Published

A vue3 component to crop and optimize your images before you upload them.

Downloads

4

Readme

vue3-image-slim README

这个组件把你的图片文件进行剪切和优化,适用于vue3。

This is a vue3 component to crop and optimize your images before you upload them. More details

demo | Vue2版本 | For Vue2

示意图sketch

安装

npm install vue3-image-slim

使用

  1. 在script中引入:

import Vue3ImageSlim from "vue3-image-slim"

  1. 在components中:
components:{
  Vue3ImageSlim
}
  1. 在methods中:
  getDataURL(dataURL){
    console.log(dataURL);
    // 获取到剪裁并优化后的base64格式字符串,你可以把它渲染到<img>标签内
  },
  getFile(file){
    // 获取到剪裁并优化后的File对象,你可以用它上传
    console.log(file);
  }
  1. 在template中:
  <vue3-image-slim
    o="C"
    :w="300"
    :h="300"
    @getDataURL="getDataURL"
    @getFile="getFile"
  />

参数说明

  • o(String),可选 剪切图片的原点,可以使用的值是:
    • LT, left-top, 左上角,这是缺省值
    • RT, right-top, 右上角
    • C, center point, 中心点
    • LB, left-bottom, 左下角
    • RB, right-bottom, 右下角
  • w(Number),可选 目标图片的宽度,缺省值是原图宽度
  • h(Number),可选 目标图片的高度,缺省值是原图高度
  • disabled(Boolean),可选 是否禁止点击文件选择按钮,缺省值否

Install

npm install vue3-image-slim

Usage

  1. in script tag:

import Vue3ImageSlim from "vue3-image-slim" import "vue3-image-slim/dist/default.css"

  1. put it into components:
components:{
  Vue3ImageSlim
}
  1. create the methods:
  getDataURL(dataURL){
    // get the cropped and optimized base64 string to render on <img> tag
    console.log(dataURL);
  },
  getFile(file){
    // get the cropped and optimized file object to upload
    console.log(file);
  }
  1. use the component in template:
  <vue3-image-slim
    o="C"
    :w="300"
    :h="300"
    @getDataURL="getDataURL"
    @getFile="getFile"
  />

props

  • o(String),optional, the original point to crop, valid values as below:
    • LT, left-top, default
    • RT, right-top
    • C, center point
    • LB, left-bottom
    • RB, right-bottom
  • w(Number),optional, px width of final image, default the original width
  • h(Number),optional, px height of final image, default the original height
  • disabled(Boolean),optional, if to disable the file selection button, default false