Socket
Book a DemoInstallSign in
Socket

@neosjs/cropper

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neosjs/cropper

Vue图片裁剪器

1.0.2
latest
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

@neosjs/cropper

Vue图片裁剪器

安装

npm install @neosjs/cropper

使用

<script lang="ts" setup>
import NeosCropper from '@neosjs/cropper'

const cropper = ref(null)
const option = ref({
  img:'xxxxxxx', // 图片地址
  full: false,
  quality:1,
  fileExt: 'png', // 输出类型
  canMove: false, // 是否可以移动图片
  fixedSize: false, // 固定截图框大小
  original: false, // 是否显示原图按钮
  canMoveBox: true, // 截图框是否可以拖动
  autoCrop: false, // 是否自动截图
  // 只有自动截图开启 宽度高度才生效
  autoCropWidth: 200, // 自动截图宽度
  autoCropHeight: 150, // 自动截图高度
  centerBox: false, // 截图框是否被限制在图片里
  high: false, // 是否按高清
  cropData: {}, // 截图框的数据
  enlarge: 1, // 截图框的放大倍数
  mode: 'contain', // 截图框的模式
  maxImgSize: 3000, // 最大允许的图片大小
  limitMinSize: [50, 50], // 截图框的最小大小
  fixed: false, // 是否开启截图框宽高固定比例
  fixedNumber: [2, 1], // 截图框的宽高比例
  fillColor: '', // 截图框的背景颜色
  outlineColor: '#1c7ed6', // 截图框的线条颜色
  showGrid: true // 是否显示网格
})

const imgLoad = () => {
  console.log('图片加载完成')
}
const realTime = (data: any) => {
  previews.value = data
}
const startCrop = () => {
  crap.value = true
  cropper.value.startCrop()
}
const stopCrop = () => {
  crap.value = false
  cropper.value.stopCrop()
}
const clearCrop = () => {
  cropper.value.clearCrop()
}
</script>

<template>
  <div>
    <NeosCropper
      ref="cropper"
      v-bind="option"
      @real-time="realTime"
      @img-load="imgLoad"
      @img-load-error="imgLoad"
    />
    <section class="block">
      <p>截图预览</p>
      <div
        class="show-preview"
        :style="{
          width: previews.w + 'px',
          height: previews.h + 'px',
          overflow: 'hidden',
          margin: '5px'
        }"
      >
        <div :style="previews.div">
          <img :src="previews.url" :style="previews.img" />
        </div>
      </div>
    </section>
  </div>
</template>

API

方法名说明参数
startCrop开始截图-
stopCrop停止截图-
clearCrop清除截图-
destroyCrop销毁截图-
rotateLeft左旋转-
rotateRight右旋转-
changeScale缩放图片Number
downloadImg下载图片-
getImgData获取图片数据-
getCropData获取转换成base64 的图片信息Function

事件

事件名说明返回值
on-error图片加载失败-
on-success图片加载成功-
real-time截图框实时数据Object
crop-moving截图框移动中-

参数

参数说明类型可选值默认值
img图片地址String, Blob, null, File--
quality输出图片质量Number-1
fileExt输出图片类型String-jpeg
fileScale输出图片的缩放比例Boolean-false
canScale是否开启滚轮放大缩小Boolean-false
canMove是否可以移动图片Boolean-false
canMoveBox截图框是否可以拖动Boolean-true
autoCrop是否自动截图Boolean-false
autoCropWidth自动截图宽度Number、String-0
autoCropHeight自动截图高度Number、Number、String-0
fixedRatio是否开启固定宽高比Boolean-false
fixedNumber固定宽高比例Array-[1, 1]
fixedSize是否固定截图框大小Boolean-false
original是否显示原图按钮Boolean-false
centerBox截图框是否被限制在图片里Boolean-false
showInfo是否显示截图框信息Boolean-true
high是否按高清Boolean-true
maxImgSize最大允许的图片大小Number-2000
fillColor导出时,填充背景颜色String--
cutDotColor截图框的点的颜色String-rgb(51 153 255 / 75%)
cutDotSize截图框的点的大小Number-6
cutDotRound截图框的点是否圆角Boolean-true
showGrid是否显示网格Boolean-true
gridColor网格颜色String-#eeeeee
showToolIcon显示工具栏图标ArrayzoomIn、zoomOut、rotateLeft、rotateRight、redo、save['close', 'confirm']
toolPosition工具栏位置Stringleft、center、rightright

Keywords

neosjs

FAQs

Package last updated on 16 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.