Skip to content

Execution freezes when calling rotate + extract + resize with transparency in background #3722

@pedro-pedrosa

Description

@pedro-pedrosa

Possible bug

Is this a possible bug in a feature of sharp, unrelated to installation?

  • Running npm install sharp completes without error.
  • Running node -e "require('sharp')" completes without error.

If you cannot confirm both of these, please open an installation issue instead.

Are you using the latest version of sharp?

  • I am using the latest version of sharp as reported by npm view sharp dist-tags.latest.

If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.

If you are using another package which depends on a version of sharp that is not the latest, please open an issue against that package instead.

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

  System:
    OS: Linux 5.15 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Core(TM) i7-4700HQ CPU @ 2.40GHz
    Memory: 2.40 GB / 15.50 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
    Yarn: 1.21.1 - /usr/bin/yarn
    npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm
    Watchman: 4.9.0 - /home/linuxbrew/.linuxbrew/bin/watchman
  npmPackages:
    sharp: ^0.32.1 => 0.32.1 

What are the steps to reproduce?

Download the sample image then run the example script on it

What is the expected behaviour?

I should get an output, but the toBuffer promise never resolves. If I change the height of the extract transform to 1439 or lower, it works. If I change the resize params to 1920x1080, it works. If I change the bg color param of the rotate transformation to { r: 0, g: 0, b: 0, alpha: 1 }, it works.

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem

var sharp = require('sharp')
var fs = require('fs')
var input = fs.readFileSync('./o.jpeg')
var result = sharp(input)
result = result.rotate(28, { background: { r: 0, g: 0, b: 0, alpha: 0 } })
result = result.extract({ left: 341, top: 1093, width: 3521, height: 2279 })
result = result.resize({ width: 640, height: 360, fit: 'outside', background: { r: 0, g: 0, b: 0, alpha: 0 }})
result = result.jpeg()
result.toBuffer().then(o => {
  fs.writeFileSync('./o2.jpeg', o)
})

Please provide sample image(s) that help explain this problem

o

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions