lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
28.41k stars 1.28k forks source link

Trim cuts off top of my image #4148

Open aleclloyd-jumbo opened 6 days ago

aleclloyd-jumbo commented 6 days ago

Possible bug

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

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

Are you using the latest version of sharp?

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?

Does this problem relate to file caching?

The default behaviour of libvips is to cache input files, which can lead to EBUSY or EPERM errors on Windows. Use sharp.cache(false) to switch this feature off.

Does this problem relate to images appearing to have been rotated by 90 degrees?

Images that contain EXIF Orientation metadata are not auto-oriented. By default, EXIF metadata is removed.

What are the steps to reproduce?

What is the expected behaviour?

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

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

lovell commented 6 days ago

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

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

aleclloyd-jumbo commented 6 days ago

async function save(fileName) { sharp(fileName) .trim() .toFile("/output/" + fileName); }

aleclloyd-jumbo commented 6 days ago

Original and trimmed image.zip

lovell commented 5 days ago
$ vipsheader "08715600249637_C1N1 - Original.tiff"
08715600249637_C1N1 - Original.tiff: 3600x3600 uchar, 5 bands, srgb, tiffload

This TIFF image has 2 alpha channels and the second of these is being used - please see https://github.com/lovell/sharp/issues/2266

alpha1 alpha2