1.0.0 • Published 1 year ago

@neosjs/merge-images v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

@neosjs/merge-images

将多个图像合并成一个图像

安装

npm install @neosjs/merge-images

使用方法

import mergeImages from '@neosjs/merge-images'

const images = [
  'https://example.com/image1.png',
  'https://example.com/image2.png',
  'https://example.com/image3.png',
]

mergeImages(images, {
  width: 800,
  height: 600,
  format: 'image/png',
  quality: 1,
  crossOrigin: 'anonymous',
}).then((base64: string) => {
  console.log(base64)
})

参数

参数说明类型可选值默认值
images图像列表Array<Sourcestring>--
options配置项Options--
options.width合并后的图像宽度number--
options.height合并后的图像高度number--
options.format输出图像格式string'image/png'、'image/jpeg'、'image/webp''image/jpeg'
options.quality输出图像质量number0 ~ 10.75
options.crossOrigin跨域属性string'anonymous'、'use-credentials''anonymous'

接口类型

export interface Options {
  format?: string
  quality?: number
  width?: number | undefined
  height?: number | undefined
  Canvas?: any
  crossOrigin?: string
  Image?: any
  [key: string]: any
}
export interface Source {
  src?: string
  x?: number
  y?: number
  opacity?: number
}
1.0.0

1 year ago