jimp-dev/jimp

Cannot create new Jimp from Buffer

开放

#932 创建于 2020年8月27日

 (0 条评论) (1 个反应) (0 位负责人)JavaScript (785 个派生)batch import
bughelp wanted

仓库指标

星标
 (13,218 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Expected Behavior

Would like to create a new Jimp object from a buffer

Current Behavior

with this code:

new Jimp({
    data: Buffer.from(
      `<svg><rect x="0" y="0" width="${width}" height="${height}" rx="${width / 2}" ry="${height / 2}" /></svg>`
    ), 
    width: width, 
    height: height
  });

I get the error message:

Error: w and h must be numbers

Steps to Reproduce

run this code :

new Jimp({
    data: Buffer.from(
      `<svg><rect x="0" y="0" width="${width}" height="${height}" rx="${width / 2}" ry="${height / 2}" /></svg>`
    ), 
    width: width, 
    height: height
  });

Context

Basically what I'm trying to do is generate a Jimp object with rounded corners to use as a mask on another image (i.e. with myImage.composite(maskFromBuffer,0,0)

  • Jimp Version: 0.9.8
  • Operating System: MacOS
  • Node version:v12.17.0

贡献者指南