question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

resize() after composite() cause error

See original GitHub issue

Hi,

There is a wierd issue when Im trying to resize() after composite(), the source is:

sharp({
    create: {
        width: 789,
        height: 789,
        channels: 4,
        background: '#bfff00'
    }
}).png().composite([{ input: content }]).resize(192).toBuffer((err, data) => {
    if (err)
        return callback(err);
    this.emitFile(target, data);
    callback(null, '');
});

And it halted with Image to composite must have same dimensions or smaller.

If I deleted .resize(192), it works fine.

If I deleted .png(), the same error would be occurred again.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
lovellcommented, Mar 30, 2019

You’ll need to break this into two pipelines, something like (untested):

sharp({
  create: {
    width: 789,
    height: 789,
    channels: 4,
    background: '#bfff00'
  }
})
  .composite([{
    input: content
  }])
  .png()
  .toBuffer()
  .then(data => sharp(data)
    .resize(192)
    .toBuffer()
  )
  .then( ... );
1reaction
djardinecommented, Jan 8, 2020

Think @johannwagner is correct above, but regardless of the call order, to me it would seem to make more sense if the resize() is applied to the final composite image, not just the input base image, but not sure how others feel about that…?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does an SWT Composite sometimes require a call to ...
Looks to me like the layout's cache is outdated and needs to be refreshed. Layouts in SWT support caches, and will usually cache...
Read more >
Resizing or Scaling -- IM v6 Examples - ImageMagick
Resizing will cause drastic changes to an image, and avoiding or minimizing ... That is, any position is preserved for later use by...
Read more >
Resizing browser flickers black on all window managers
What steps will reproduce the problem? 1. Resize a browser window (with a window manager which draws the window as you resize) What...
Read more >
Resizing images - High performance Node.js image processing
Resize large images in common formats to smaller, web-friendly JPEG, PNG, WebP, GIF and AVIF images of varying dimensions.
Read more >
ITOM Practitioner Portal - Micro Focus
Resizing the browser window opened with the HTML5 GRE Web Plug-in causes an error and reloads the page. Cause. This is a known...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found