save binary image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
bronstein87
Posts: 5
Joined: 2017-01-14T21:56:44-07:00
Authentication code: 1151

save binary image

Post by bronstein87 »

trying to save binary image:

Image image;
image.size(Geometry(10000,10000));
image.type(BilevelType);
image.write("D:\\copy_check.tiff");

but after saving file has size 195 MB. Why? After all, if it was converted into a binary, it's size must be about 10000*10000*1bit =10 MB.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: save binary image

Post by fmw42 »

What does identify -verbose copy_check.tiff tell you about the resulting image. It may be 8/1 bits or 16/1 bits palette or truecolor.

Try adding depth 1 and compress group4 or fax.

What version of Imagemagick are you using and what OS/platform?

Please always provide your IM version and platform when asking questions.
bronstein87
Posts: 5
Joined: 2017-01-14T21:56:44-07:00
Authentication code: 1151

Re: save binary image

Post by bronstein87 »

fmw42 wrote: 2017-01-28T15:08:40-07:00 What does identify -verbose copy_check.tiff tell you about the resulting image. It may be 8/1 bits or 16/1 bits palette or truecolor.

Try adding depth 1 and compress group4 or fax.

What version of Imagemagick are you using and what OS/platform?

Please always provide your IM version and platform when asking questions.
Version:ImageMagick-7.0.4-6-Q16-x86. Platform: Windows 7.
Thank you. image.depth(1) helped. but, there is a new problem. when i'm making bigger image , for example:
Image* image=new Image(Geometry(1,1),"black");
image->type(BilevelType);
image->depth(1);
image->resize(Geometry(35000,35000));

it returns error "unable to extend cache, no space left on device". but it's strange, because this image after resize will have size: 35000*35000*1bit=125 MB , it is not much and i don't understand why it says that there is no enougth space.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: save binary image

Post by snibgo »

35000*35000 is 1225 million pixels. V6 Q16 needs 8 bytes/pixel of memory (I'm not sure about v7). So that is 9.8 GB.

The depth and type is only relevant once the image has been created, and is to be written to file.
snibgo's IM pages: im.snibgo.com
Post Reply