Page 1 of 1

Image filesize changes after writing to Blob. Bug?

Posted: 2013-02-20T23:49:31-07:00
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

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

Posted: 2013-02-21T04:30:42-07:00
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.

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

Posted: 2013-02-21T04:48:52-07:00
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?

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

Posted: 2013-02-21T09:42:46-07:00
by fmw42
Compression/Decompression is automatic with JPG format data and causes differences between input and output