Image filesize changes after writing to Blob. Bug?

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
vladimir_ff
Posts: 18
Joined: 2011-11-18T05:12:05-07:00
Authentication code: 8675308

Image filesize changes after writing to Blob. Bug?

Post by vladimir_ff »

I have an image https://dl.dropbox.com/u/79309031/image.jpg
The size of file is 1650 bytes.
My code:

Code: Select all

Image newimage( "image.jpg" );
cout << newimage.fileSize() << endl; // point1
Blob blob1;
newimage.write(&blob1);
cout << newimage.fileSize() << endl; // the same call as in point1!
And the output is:
1650
1653
What happened?
Why filesize has changed after writing to blob?
IM 6.7.6.9
Ubuntu 11.04
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Image filesize changes after writing to Blob. Bug?

Post by magick »

Not a bug, JPEG is lossy and its not unusual for the file size to change when its recompressed. You can adjust the compression quality to reduce the output image size.
vladimir_ff
Posts: 18
Joined: 2011-11-18T05:12:05-07:00
Authentication code: 8675308

Re: Image filesize changes after writing to Blob. Bug?

Post by vladimir_ff »

Yes, but where is recompression in my code?
I was sure, that Image::write function doesn't change the object, it just writes data somewhere with optional parameters.
Could you please clarify?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image filesize changes after writing to Blob. Bug?

Post by fmw42 »

Compression/Decompression is automatic with JPG format data and causes differences between input and output
Post Reply