IM Version: stable 7.0.5-0
Is it possible to edit an images pixels directly in such a way where when writing out the image the file size is the same size in bytes? I wouldn't be adding or removing pixels or changing the image format/colorspace, I would only change the pixels colors, so theoretically the image should take up the same amount of bytes.
When writing out an image I'm guessing that ImageMagick has it's own algorithm and metadata and thus writes out the image differently from the original format. Is this correct? If so, how would I simply read the pixels from an image, modify them, and then write them back to the same image with the same formatting/metadata?
UPDATE
I ran the contrast sample code on a couple different image formats and the file sizes would always change. Correct me if I'm wrong but doesn't the same just change the pixel rgb colors, so the file size shouldn't change?
It might be worth noting that the sample contrast code isn't updated to work for IM 7 so I had to update a couple things:
code gist here
And I used clang to compile:
Code: Select all
clang contrast.c -std=c11 -o contrast `pkg-config --cflags --libs MagickWand`
28487 bytes -> 34985 bytes (size increase)
http://users.usinternet.com/nkelebay/Im ... _Melon.jpg
115739 bytes -> 96885 bytes (size decrease)
http://pngimg.com/uploads/cat/cat_PNG1631.png