BMP encoder

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
wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

BMP encoder

Post by wizard29 »

Hello, everyone.

I found an issue of BMP encoder that looks like a bug.

When I try to save an image with 10000x10000 pixel dimension I catch an exception "Memory allocation failed" at bmp.c line 1715.
Why the BMP encoder tries to allocate so match memory at once ? How can I fix the issue?

I use Magick++, IM 6.9.0-7 for Win32.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: BMP encoder

Post by dlemstra »

That is an implementation issue. This coder allocates the whole image instead of just a row. I will take a look if I can change this behavior.

EDIT:

You might also want to take a look at your limits. My machine can allocate the memory without any problems and could execute the following:

Code: Select all

convert logo: -scale 10000x10000! d:\logo.bmp
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

Re: BMP encoder

Post by wizard29 »

Hi.

It works fine in case of an application process only save an image. But if the application heap is partially used (about 30% for 32-bit application) for other reasons memory allocation can "randomly" fails. I guess It is not good idea to allocate so big memory block at once. May be it would be an option for the encoder.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: BMP encoder

Post by dlemstra »

I agree with you, but that would mean a rewrite of the bmp coder. I will put this on my todo list :)
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: BMP encoder

Post by magick »

Set your area resource limit to 0. From the command-line its -limit area 0. That should force the pixels to disk rather than memory and allow your command to complete.
wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

Re: BMP encoder

Post by wizard29 »

It does not help in my case.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: BMP encoder

Post by magick »

Unfortunately we do not have access to a Win32 host. We did try Win64 and this command worked without complaint:
  • convert logo: -scale 10000x10000! logo.bmp
We even tried this on a Windows 7 virtual instance with 1GB of memory and again it completed without complaint. We're using ImageMagick 6.9.0-9, the current release.
wizard29
Posts: 58
Joined: 2014-03-21T00:40:16-07:00
Authentication code: 6789
Location: Russia, Saint Petersburg
Contact:

Re: BMP encoder

Post by wizard29 »

Physical memory is not a restriction for the 64-bit adress space in general.
Post Reply