Magick++ Compressing and Decompressing files
I've found the compressType()-Method of the Image class in ImageMagick Magick++. I searched for examples how to use it, but there isn't much of information about that.
Can someone give me an example of how to open a compressed file and how to compress开发者_StackOverflow中文版 & save an image?
Thank you so much!
Usage:
Magick::Image.compressType(CompressionType)
The list of available compression types: http://www.imagemagick.org/Magick++/Enumerations.html#CompressionType
Example:
#include "Magick++.h"
#include <iostream>
int main()
{
Magick::Image image;
try{
image.read("image.jpg");
image.compressType(JPEGCompression);
image.write("image.jpg");
catch(Magick::Exception &error_)
{std::cout << "Caught exception: " << error_.what() << std::endl;}
}
If the compression type specified is incompatable with the image, ImageMagick selects a compression type compatable with the image type. BTW, these compression types and the method compressType are for expressing the desired compression type when encoding an image (Not for adding the image to an archive). Note, I haven't compiled/tested the above example.
精彩评论