Images whitening

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
amitkanfer
Posts: 1
Joined: 2015-02-17T05:05:55-07:00
Authentication code: 6789

Images whitening

Post by amitkanfer »

Hello experts,
I need to "whiten" images for security reasons.
Meaning - take a certain image, make something with it to reduce the chance of malicious "code" in it.
What i thought is to convert the image to a different format, and then convert it back to the original format again.

so if i have a vector of bytes of a PNG image, i'll do something like this:

Code: Select all

                        Magick::Blob source_blob(buffer->data(), buffer->size());
                        Magick::Image image(source_blob);
                        image.magick("BMP");
                        Magick::Blob intermediate_blob;
                        image.write(&intermediate_blob);
                        result_image.read(intermediate_blob);
                        result_image.magick("PNG");
                        Magick::Blob blob;
                        result_image.write(&blob);
                        uchar* charBuf = (uchar*)blob.data();
                        buffer->assign(charBuf, charBuf + blob.length());
My questions:
1. Is this the best approach? is there something better / else i should do?
2. I assume Magick recognizes the source image format by the first bytes in the data, and i assume that this is the reason why i'm getting an exception when trying to make an image object out of a blob that represents an ICO format... how can i overcome this? i know what is the source format, but i don't want to use the HD and i don't know what is the geometry of the source image.
3. Regarding ICO format... How do you handle layers? if i convert the format to PNG, which layer will be converted?

thanks alot!
Amit
Post Reply