Skip to content

"Error: linear: vector must have 1 or 2 elements" raised when resizing a b&w png image #411

@janaz

Description

@janaz

Hi Lovell,

Sharp is failing to resize a png file with the following metadata:

{ format: 'png',
  width: 1653,
  height: 2339,
  space: 'b-w',
  channels: 1,
  density: 200,
  hasProfile: false,
  hasAlpha: false }

To reproduce, please run the following:

var sharp = require('sharp');
var i = sharp('image.png');

i.embed() // works without embed
  .resize(100, 100)
  .background({r:0,g:0,b:0,a:0}) // works with a:1
  .toBuffer(function(err, output, info) {
    if (err) {
      throw err;
    } else {
      console.log("All good")
    }
  });

The error thrown is Error: linear: vector must have 1 or 2 elements

It works when 'embed()' is not used or the alpha channel in the background color is set to 1

I created a repo that showcases the issue and includes the b&w png file: https://github.com/janaz/sharp-png-issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions