Bug in BMP file retrieved from scanner

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
DeGriz
Posts: 3
Joined: 2013-09-03T01:55:49-07:00
Authentication code: 6789

Bug in BMP file retrieved from scanner

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Bug in BMP file retrieved from scanner

Post 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).
snibgo's IM pages: im.snibgo.com
DeGriz
Posts: 3
Joined: 2013-09-03T01:55:49-07:00
Authentication code: 6789

Re: Bug in BMP file retrieved from scanner

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Bug in BMP file retrieved from scanner

Post 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.
snibgo's IM pages: im.snibgo.com
DeGriz
Posts: 3
Joined: 2013-09-03T01:55:49-07:00
Authentication code: 6789

Re: Bug in BMP file retrieved from scanner

Post 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.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Bug in BMP file retrieved from scanner

Post 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?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Post Reply