Skip to content

crash on malformed png files #185

@Fil

Description

@Fil

Steps To Reproduce The Error

echo "hello" > file.png
❯ imageoptim --imagealpha  file.png
i Running ImageAlpha...
! Command failed with exit code 2 (ENOENT): /Applications/ImageAlpha.app/Contents/MacOS/pngquant --ext=.png --force --skip-if-larger --speed=1 --quality=65-80 256 -- /var/folders/57/f83bftsx79b9ylc2gzbdmdfw0000gp/T/imageoptim-cli/file.png

! Please raise an issue at https://github.com/JamieMason/ImageOptim-CLI/issues

    Error: Command failed with exit code 2 (ENOENT): /Applications/ImageAlpha.app/Contents/MacOS/pngquant --ext=.png --force --skip-if-larger --speed=1 --quality=65-80 256 -- /var/folders/57/f83bftsx79b9ylc2gzbdmdfw0000gp/T/imageoptim-cli/file.png
        at makeError (/usr/local/Cellar/imageoptim-cli/3.0.2/libexec/lib/node_modules/imageoptim-cli/dist/imageoptim:6571:11)
        at handlePromise (/usr/local/Cellar/imageoptim-cli/3.0.2/libexec/lib/node_modules/imageoptim-cli/dist/imageoptim:6368:26)
        at process._tickCallback (internal/process/next_tick.js:68:7)

Expected Behaviour

ignore or report malformed png files

Actual Behaviour

crash

Version Numbers or N/A

  • macOS: 10.15.7
  • /Applications/ImageOptim.app: 1.8.8 (brew)
  • /Applications/ImageAlpha.app: 1.5.1 (brew)
  • /Applications/JPEGmini.app: N/A

Help Needed

would the test at

supportedFileTypes.indexOf(extname(filePath)) !== -1;
be complemented by a magic number test on the actual file's contents?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions