Menu

#26 How to check for bad input or corrupted input file

v1.0_(example)
closed
None
5
2015-11-19
2015-11-17
nikhil
No

I am converting files from one format to another but before that I want to check if the input file is correct or not. I tried making use of readImage but, when I give corrupted input file it aborts with a Segmentation Fault. Can you suggest, which API to be used for checking if the input is supported by the GraphicsMagick?

Discussion

  • nikhil

    nikhil - 2015-11-17

    Issue is now fixed(segfault is no longer seen). This was due to a NULL pointer issue. Still if you have any other API for this, please let me know.
    thanks

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2015-11-19

    GraphicsMagick is not a file validator. Validating file formats requires special software. For example, there is 'pngcheck' for the PNG format.

    Given compression algorithms and many other factors, it may not be possible to validate a file with any tool by simply reading it.

    If GraphicsMagick returns an image and does not report a warning or error, then you can use your eyes to check if the image seems ok. If there is reference output in some other format, then you could use 'gm compare' to check if the returned image pixels are the same. However, this still does not validate that the metadata is correct.

    The GraphicsMagick test suite operates by doing various checks such as verifying that the returned image has a particular reference checksum, or comparing the returned image against a reference image, or simply verifying that consistent results are obtained via a read/write/read/write/read cycle (comparing image from last two reads). The test suite serves to validate GraphicsMagick rather than input image files.

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2015-11-19
    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB