Skip to content

Phashion crashes on calling mh_fingerprint #113

@spyderdfx

Description

@spyderdfx

Hi.
Looks like phashion-1.2.0 doesn't handle exceptions in #mh_fingerprint method, more specifically in pHash C code.

For example, calling #fingerprint on non-existing file produces RuntimeError:

> Phashion::Image.new('/tmp/20251203-6-1qsykyq').fingerprint

[CImg] *** CImgIOException *** [instance(0,0,0,0,(nil),non-shared)] CImg<unsigned char>::load() : Failed to open file '/tmp/20251203-6-1qsykyq'.
RuntimeError: Unknown pHash error

but calling #mh_fingerprint in the same situation crashes rails console (sigabrt):

> Phashion::Image.new('/tmp/20251203-6-1qsykyq').mh_fingerprint

[CImg] *** CImgIOException *** [instance(0,0,0,0,(nil),non-shared)] CImg<unsigned char>::load() : Failed to open file '/tmp/20251203-6-1qsykyq'.
terminate called after throwing an instance of 'cimg_library::CImgIOException'
  what():  [instance(0,0,0,0,(nil),non-shared)] CImg<unsigned char>::load() : Failed to open file '/tmp/20251203-6-1qsykyq'.
ERROR: 134

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