You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Adding sharp.cache(false) does not fix this problem.
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.
To auto-orient pixel values use the parameter-less rotate() operation.
Using rotate() or keepExif() does not fix this problem.
What are the steps to reproduce?
Import a 32x32 PNG image with some whitespace into sharp
Attempt to crop the image to only the opaque pixels with .trim()
The resulting image will sometimes have stretched pixels on the right side, or may have trimed any opaque floating pixels entirely
What is the expected behaviour?
The image should be trimmed to remove whitespace from all edges, only containing the unmodified opaque area without removing floating pixels or stretching the right edge.
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
After testing some more, it only seems to occur when specifying max colours between 9 and 129 when using .png(). If a number of colours isn't specified at all, it seems to output the expected result consistently.
These look like dithering artefacts when mapping pixel values to a palette-based PNG. For line art you can usually reduce/remove these via .png({ dither: 0 }).
Possible bug
Is this a possible bug in a feature of sharp, unrelated to installation?
npm install sharp
completes without error.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?
sharp
as reported bynpm 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: Windows 11 10.0.22631
CPU: (20) x64 13th Gen Intel(R) Core(TM) i7-13700H
Memory: 20.07 GB / 31.53 GB
Binaries:
Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
npmPackages:
sharp: ^0.33.4 => 0.33.4
Does this problem relate to file caching?
The default behaviour of libvips is to cache input files, which can lead to
EBUSY
orEPERM
errors on Windows.Use
sharp.cache(false)
to switch this feature off.sharp.cache(false)
does not fix this problem.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.
To auto-orient pixel values use the parameter-less
rotate()
operation.To retain EXIF Orientation use
keepExif()
.Using
rotate()
orkeepExif()
does not fix this problem.What are the steps to reproduce?
What is the expected behaviour?
The image should be trimmed to remove whitespace from all edges, only containing the unmodified opaque area without removing floating pixels or stretching the right edge.
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
Please provide sample image(s) that help explain this problem
Original image
![input](https://private-user-images.githubusercontent.com/80712417/336838557-ab898296-8415-4708-beaf-7f9ed6e50674.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk2NTk2NTAsIm5iZiI6MTcxOTY1OTM1MCwicGF0aCI6Ii84MDcxMjQxNy8zMzY4Mzg1NTctYWI4OTgyOTYtODQxNS00NzA4LWJlYWYtN2Y5ZWQ2ZTUwNjc0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI5VDExMDkxMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTY5OTBlYzU2Y2E2YmViZThhNzkwY2Q0NjU1NzhiOWQyMzViYjY0MjI1YmQyZWQ0NGY2OGM0MjczMjI5YTVmZjMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.pDhZ8JDAg4kP7OmQ6JIGdak-0aScSk-YRIybg-11xPY)
![output](https://private-user-images.githubusercontent.com/80712417/336838750-6b00b8fa-0a22-4a64-8081-2a7cca388ed3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk2NTk2NTAsIm5iZiI6MTcxOTY1OTM1MCwicGF0aCI6Ii84MDcxMjQxNy8zMzY4Mzg3NTAtNmIwMGI4ZmEtMGEyMi00YTY0LTgwODEtMmE3Y2NhMzg4ZWQzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI5VDExMDkxMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE5MDBmZGY2ZjQwNzQyNzBjZjA5MTk3ZDM5ZjU4ZGJhNzA4N2YxYjFkZGZmNTY5YzdmZDZlMTMyNTI4OGViMzQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.ZVQW3vaKXTwmpNeKG3vpWtr1Pie4snBRe79QtUruueY)
![output_intended](https://private-user-images.githubusercontent.com/80712417/336838973-24f18582-71a5-41c6-ad3d-69c1639a3834.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk2NTk2NTAsIm5iZiI6MTcxOTY1OTM1MCwicGF0aCI6Ii84MDcxMjQxNy8zMzY4Mzg5NzMtMjRmMTg1ODItNzFhNS00MWM2LWFkM2QtNjljMTYzOWEzODM0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI5VDExMDkxMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTRhMjc1YmFiNjNkMzJhZmY3M2JjMTliYzgyYWE3NmIxNjFkNmZjMGE0NjRhMTM2NTQ0Y2E1YjcyMzk1NjZjMzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.hbOeauCYZu2oPZztg6ZL_oscUhq6RENpSqq-2cNz8YU)
Trimmed image, with edge artifact
Expected output
The text was updated successfully, but these errors were encountered: