Error during conversion of images that view fine: "length and filesize do not match"

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
IanL
Posts: 3
Joined: 2016-07-22T07:07:58-07:00
Authentication code: 1151

Error during conversion of images that view fine: "length and filesize do not match"

Post by IanL »

I have no control of the input .bmp files (I am converting files from a game's user created scenarios into .jpg files for use on the web) and all the viewers and editors I have used read them and display them OK but when I run convert the majority of them produce this (and no jpg file):

Code: Select all

convert -resize x220^> "The Battle for Borgo Cascino.bmp" "The Battle for Borgo Cascino.jpg"
convert: length and filesize do not match `The Battle for Borgo Cascino.bmp' @ warning/bmp.c/ReadBMPImage/809.
I have seen this error referenced from 13 years ago but nothing recent is there anything I can do to have this warning ignored or otherwise workaround this?

I am running this on Windows 10 with ImageMagick-7.0.2-Q16 64 bit.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Error during conversion of images that view fine: "length and filesize do not match"

Post by snibgo »

Can you supply an input file that shows the problem? You can upload to somewhere like dropbox.com and paste the link here.
snibgo's IM pages: im.snibgo.com
IanL
Posts: 3
Joined: 2016-07-22T07:07:58-07:00
Authentication code: 1151

Re: Error during conversion of images that view fine: "length and filesize do not match"

Post by IanL »

Here is a sample image.
https://dl.dropboxusercontent.com/u/286 ... ascino.bmp

However I may have jumped the gun and really have a different problem - aka user error.

What I really want to do is convert the whole directory of images and the command I was trying to use was this to convert all .bmp images :

convert -resize x220^> *.bmp test\

I realized my error when I went to copy the file for you to look at and realized that there was a .jpg file there form my sample command line.

My attempt to convert *.bmp and put the files in the directory test failed to create output .jpg files but still touched and reported the warning for all the .bmp files. So, obviously I'm OK with warnings appearing for files that are not quite right but I cannot figure out how to convert to jpg files and copy to another directory. I have tried:

convert -resize x220^> *.bmp test\*.jpg
convert -resize x220^> *.bmp test
convert -resize x220^> *.bmp test/

I will continue to read the documentation...
IanL
Posts: 3
Joined: 2016-07-22T07:07:58-07:00
Authentication code: 1151

Re: Error during conversion of images that view fine: "length and filesize do not match"

Post by IanL »

So it seems the recommended way to go is to use mogrify instead of convert. This does the job:

mogrify -format jpg -path .\test -resize x220^> *.bmp
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Error during conversion of images that view fine: "length and filesize do not match"

Post by snibgo »

Yes, use "mogrify".

Note the the correct syntax for "convert" is: read the input, do the 1processing, write the output. And don't use wildcards in the output. "Convert" is normally used when we want to combine inputs in a certain way. If we want the same processing to be done on a batch of files, with one output per input, "mogrify" is the tool to use.
snibgo's IM pages: im.snibgo.com
Post Reply