Page 1 of 1

Bug in BMP file retrieved from scanner

Posted: 2013-09-03T06:47:55-07:00
by DeGriz
I am using WIA interface to retrieve scanned images. Scanner returns me file named WIA*.tmp.jpg (for example: WIA6F3.tmp.jpg). This is actually a BMP file. But even when I rename it I still get an error:
identify.exe: Length and filesize do not match `C:\Users\Kahanov.Andrey\Desktop\WIA9773.tmp.jpg' @ error/bmp.c/ReadBMPImage/813.
It would be a big issue (because program actually gives away the image information), but there is no way (at least not through im4java) to tell if it is the critical error or not. ImageMagick Display doesn't display the image either. But standart Windows Viewer (Windows 7), VnView, Microsoft Office 2010, Paint.NET, GIMP and my app display it correctly.
I uploaded it to Box https://app.box.com/s/wqzkob059molrbo57biy
I've seen that issue with previous versions (4, 5) addressed on forum.

Re: Bug in BMP file retrieved from scanner

Posted: 2013-09-03T07:42:13-07:00
by snibgo
It is a BMP file, which some programs can read successfully, including convert, eg:

Code: Select all

convert WIA9773.tmp.jpg x.png
... succeeds, and the x.png looks okay (but very boring).

Re: Bug in BMP file retrieved from scanner

Posted: 2013-09-03T09:03:00-07:00
by DeGriz
Yes, convert.exe do work with it, but identify.exe does not. I don't see the reason to convert file just to get info about it. Especially if files are large (4000x3000 or larger). That was the main reason why I even used ImageMagick. Eventually I load file into program, but sometimes I need to downscale it first. And for that I need info.
PS Picture is boring, but it's just a proof of a bug.

Re: Bug in BMP file retrieved from scanner

Posted: 2013-09-03T09:43:35-07:00
by snibgo
Identify does work, with or without "-verbose". Eg:

Code: Select all

D:\web\im>%IM%identify WIA9773.tmp.jpg
WIA9773.tmp.jpg BMP 1276x1760 1276x1760+0+0 8-bit sRGB 256c 2.247MB 0.000u 0:00.001
identify.exe: Length and filesize do not match `WIA9773.tmp.jpg' @ error/bmp.c/R
eadBMPImage/814.

Re: Bug in BMP file retrieved from scanner

Posted: 2013-09-03T22:37:19-07:00
by DeGriz
But nevertheless it still ends up returning error code after execution. There is no guarantee the error was not critical. If it was in some sort of additional data - that would be fine. But there is a message in the error stream and a error code that the program return... I will rewrite some part of im4java. BUT! imdisplay.exe still does NOT work! And that is definitely a bug.

Re: Bug in BMP file retrieved from scanner

Posted: 2013-09-04T00:11:50-07:00
by dlemstra
It is a bug in the software that created your BMP. The header of your file reports a different size then the actual file size. More info here: http://en.wikipedia.org/wiki/BMP_file_f ... ile_header. ImageMagick reports it as a error if the header contains a higher size and a warning if it is lower:

Code: Select all

    if ((MagickSizeType) bmp_info.file_size > GetBlobSize(image))
      (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
        "LengthAndFilesizeDoNotMatch","`%s'",image->filename);
    else
      if ((MagickSizeType) bmp_info.file_size < GetBlobSize(image))
        (void) ThrowMagickException(exception,GetMagickModule(),
          CorruptImageWarning,"LengthAndFilesizeDoNotMatch","`%s'",
          image->filename);
The header of your file contains a higher size so it will be reported as an error. I am not sure why there is a difference but maybe magick can explain this?