Skip to content

Enhancement: improve warning/error messages from GeoTiff images (currently reports "Unknown error") #4465

Closed

Description

@tkleinke

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: macOS 15.1
    CPU: (8) arm64 Apple M2
    Memory: 81.58 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
Binaries:
    Node: 22.18.0 - /Users/kleinke/.nvm/versions/node/v22.18.0/bin/node
    npm: 10.9.3 - /Users/kleinke/.nvm/versions/node/v22.18.0/bin/npm
npmPackages:
    sharp: 0.34.4 => 0.34.4

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.

  • 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.

  • To retain EXIF Orientation use keepExif().

  • Using rotate() or keepExif() does not fix this problem.

What are the steps to reproduce?

The error occurs when calling toBuffer for a GeoTiff file. It occurred for all GeoTiff files i tried, while all other tiff files worked, so I assume that GeoTiff is the problem here.

What is the expected behaviour?

Until sharp 0.34.2, we could use sharp to create resized JPG variants of GeoTiff files. With 0.34.3 und 0.34.4, the error "Unknown error" is thrown when calling toBuffer. We run sharp in Electron, but the error also occurs when running the code below in a node script outside of Electron. I tested it on macOS 15.1 and on Windows 11.

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

Download this GeoTiff sample file from osgeo and run this code:

const sharp = require('sharp');
sharp('cea.tif').toBuffer();

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

See above.

Activity

  1. lovell commented on Oct 15, 2025

    @lovell
    Owner

    If you set the NODE_DEBUG=sharp environment variable you'll see this image generates lots of warnings:

    SHARP 343056: Unknown field with tag 33550 (0x830e) encountered
    SHARP 343056: Unknown field with tag 33922 (0x8482) encountered
    SHARP 343056: Unknown field with tag 34735 (0x87af) encountered
    SHARP 343056: Unknown field with tag 34736 (0x87b0) encountered
    SHARP 343056: Unknown field with tag 34737 (0x87b1) encountered
    SHARP 343056: Unknown field with tag 33550 (0x830e) encountered
    SHARP 343056: Unknown field with tag 33922 (0x8482) encountered
    SHARP 343056: Unknown field with tag 34735 (0x87af) encountered
    SHARP 343056: Unknown field with tag 34736 (0x87b0) encountered
    SHARP 343056: Unknown field with tag 34737 (0x87b1) encountered
    SHARP 343056: Unknown field with tag 33550 (0x830e) encountered
    SHARP 343056: Unknown field with tag 33922 (0x8482) encountered
    SHARP 343056: Unknown field with tag 34735 (0x87af) encountered
    SHARP 343056: Unknown field with tag 34736 (0x87b0) encountered
    SHARP 343056: Unknown field with tag 34737 (0x87b1) encountered
    SHARP 343056: Unknown field with tag 33550 (0x830e) encountered
    SHARP 343056: Unknown field with tag 33922 (0x8482) encountered
    SHARP 343056: Unknown field with tag 34735 (0x87af) encountered
    SHARP 343056: Unknown field with tag 34736 (0x87b0) encountered
    SHARP 343056: Unknown field with tag 34737 (0x87b1) encountered
    SHARP 343056: Unknown field with tag 33550 (0x830e) encountered
    SHARP 343056: Unknown field with tag 33922 (0x8482) encountered
    SHARP 343056: Unknown field with tag 34735 (0x87af) encountered
    SHARP 343056: Unknown field with tag 34736 (0x87b0) encountered
    SHARP 343056: Unknown field with tag 34737 (0x87b1) encountered
    SHARP 343056: Unknown field with tag 33550 (0x830e) encountered
    SHARP 343056: Unknown field with tag 33922 (0x8482) encountered
    SHARP 343056: Unknown field with tag 34735 (0x87af) encountered
    SHARP 343056: Unknown field with tag 34736 (0x87b0) encountered
    SHARP 343056: Unknown field with tag 34737 (0x87b1) encountered
    SHARP 343056: Unknown field with tag 33550 (0x830e) encountered
    SHARP 343056: Unknown field with tag 33922 (0x8482) encountered
    SHARP 343056: Unknown field with tag 34735 (0x87af) encountered
    SHARP 343056: Unknown field with tag 34736 (0x87b0) encountered
    SHARP 343056: Unknown field with tag 34737 (0x87b1) encountered
    SHARP 343056: Unknown field with tag 33550 (0x830e) encountered
    SHARP 343056: Unknown field with tag 33922 (0x8482) encountered
    SHARP 343056: Unknown field with tag 34735 (0x87af) encountered
    SHARP 343056: Unknown field with tag 34736 (0x87b0) encountered
    SHARP 343056: Unknown field with tag 34737 (0x87b1) encountered
    SHARP 343056: Unknown field with tag 33550 (0x830e) encountered
    SHARP 343056: Unknown field with tag 33922 (0x8482) encountered
    SHARP 343056: Unknown field with tag 34735 (0x87af) encountered
    SHARP 343056: Unknown field with tag 34736 (0x87b0) encountered
    SHARP 343056: Unknown field with tag 34737 (0x87b1) encountered
    SHARP 343056: error in tile 0 x 0
    SHARP 343056: error in tile 0 x 15
    

    If you trust the source of your input(s) and would like to ignore these warnings, use failOn:

    await sharp('cea.tif', { failOn: 'error' }).toBuffer();

    https://sharp.pixelplumbing.com/api-constructor/

    v0.34.3 introduced upstream improvements to warning/error handling in libtiff and libvips, which have now exposed this image as one that should previously have been failing to load.

    https://sharp.pixelplumbing.com/changelog/v0.34.3/

  2. tkleinke commented on Oct 16, 2025

    @tkleinke
    Author

    Hi @lovell, thanks for your fast and very helpful reply! Using failOn works and solves my problem for now, so I can switch back to the latest sharp version.

    However, the tags listed as warnings are all tags of the GeoTIFF standard, which means that sharp fails right now for all GeoTIFF images if run with the default settings. I think it would be better to ignore warnings for these tags completely (or give an option to do that).

  3. lovell commented on Oct 16, 2025

    @lovell
    Owner
  4. tkleinke commented on Oct 16, 2025

    @tkleinke
    Author

    I see that it's a bigger problem than I thought (here's a discussion about this as well: libvips/libvips#3996). Ignoring the warnings with failOn seems to be the best approach then. I'm closing this issue, thanks again for your assistance.

  5. neave commented on Oct 17, 2025

    @neave
    Contributor

    I'm having the same problem when processing lots of GeoTIFFs. It's unfortunate that the only workaround seems to be to be set failOn: 'error' to every single call. Ideally sharp would not break when an image has GeoTIFF tags, like it used to do. Perhaps failOn: 'error' could become the default, so we can set failOn: 'warning' when we want it to fail. Or even have a global setting in sharp.

  6. lovell commented on Oct 17, 2025

    @lovell
    Owner

    Ideally sharp would not break when an image has GeoTIFF tags, like it used to do.

    It used to let through potentially invalid/corrupt TIFF images, whereas the current version now matches the documented default behaviour of safely failing on warnings. GeoTIFF images are not really supported by libvips (or libtiff for that matter), hence the warnings.

    What I would like to do is investigate what might be possible to improve the "Unknown error" messaging as that's not very helpful on its own.

  7. reopened this on Oct 17, 2025
  8. changed the title [-]Unknown error when calling toBuffer for GeoTiff file since 0.34.3[/-] [+]Enhancement: improve warning/error messages from GeoTiff images (currently reports "Unknown error")[/+] on Oct 17, 2025
  9. neave commented on Oct 17, 2025

    @neave
    Contributor

    @lovell Yes, that would be much better as I had to a little digging to find this problem at first. Maybe it could relay the "Unknown field with tag" message, or suggest to use failOn: 'error' to suppress the warning. Thank you!

  10. added this to the v0.34.5 milestone on Oct 17, 2025
  11. lovell commented on Oct 17, 2025

    @lovell
    Owner

    Commit c1c16ed helps prevent the "Unknown error" message and will be part of v0.34.5.

  12. lovell commented on Nov 6, 2025

    @lovell
    Owner

    v0.34.5 now available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions