Profiles·Public

image-size

semver>=1.0.0postconditions6functions2last verified2026-04-17coverage score100%

Postconditions — what we check

  • imageSize · unsupported-format
    error
    WhenImage format is unsupported or buffer is not a recognized image format
    ThrowsTypeError ('unsupported file type: ...' or 'disabled file type: ...')
    Required handlingCaller MUST wrap imageSize() in try-catch as it throws synchronously on unrecognized formats.
    costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisible
    Sources[1]
  • imageSize · corrupt-image
    error
    WhenBuffer contains corrupt or truncated image data
    ThrowsTypeError ('Corrupt JPG', 'Invalid PNG', etc.)
    Required handlingCaller MUST wrap imageSize() in try-catch as it throws on corrupt image data.
    costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisible
    Sources[1]
  • imageSizeFromFile · file-not-found
    error
    WhenFile path does not exist or cannot be read
    ThrowsError (ENOENT, EACCES)
    Required handlingCaller MUST wrap imageSizeFromFile() in try-catch as it rejects on file system errors.
    costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisible
    Sources[2]
  • imageSizeFromFile · unsupported-format
    error
    WhenFile is not a recognized image format
    ThrowsTypeError ('unsupported file type: ...')
    Required handlingCaller MUST wrap imageSizeFromFile() in try-catch as it rejects on unrecognized image formats.
    costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisible
    Sources[1]
  • imageSizeFromFile · empty-file
    error
    WhenFile exists at the given path but has zero bytes (size <= 0)
    ThrowsError ('Empty file')
    Required handlingCaller MUST wrap imageSizeFromFile() in try-catch. An empty file rejects with Error('Empty file'), which is distinct from ENOENT (file missing) and from TypeError (unsupported format). Upload pipelines that check file existence before dimensions must also guard against the file being zero-length.
    costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisible
    Sources[2][3]
  • imageSizeFromFile · corrupt-image-async
    error
    WhenFile exists and is readable but contains corrupt or malformed image data
    ThrowsTypeError (e.g. 'Corrupt JPG, exceeded buffer limits', 'Invalid PNG', 'Invalid WebP', etc.)
    Required handlingCaller MUST wrap imageSizeFromFile() in try-catch. When the file contains corrupt image data, the async wrapper rejects with the same TypeError thrown by the synchronous imageSize() parser. Callers checking only for ENOENT/EACCES will miss format corruption errors from user-uploaded files.
    costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisible
    Sources[2][1]

Sources

Every postcondition cites at least one of these. Numbered to match the footnotes above.

  1. [1]github.com/image-size/image-sizehttps://github.com/image-size/image-size/blob/main/lib/index.ts
  2. [2]github.com/image-size/image-sizehttps://github.com/image-size/image-size/blob/main/lib/fromFile.ts
  3. [3]github.com/image-size/image-sizehttps://github.com/image-size/image-size/issues?q=empty+file
Need a different package?
Request a profile