I use Magick++ to process images, the codes below throw a warning:"Magick: iCCP: known incorrect sRGB profile () reported by coders/png.c:1105 (PNGWarningHandler)"
......
string img;
//assign image to this string(img)
std::list<Image> m_images;
......
Blob src_blob(image.data(), image.length());
readImages(&m_images, src_blob);//in this function throw a warning exception
if (!m_images.empty()) {
Image image = *(m_images.begin());
}
......
But if I construct Image like this:
Blob src_blob(image.data(), image.length());
Image image(src_blob);
the codes will work and no throw exception
the identify of this image:
$identify case1.png
case1.png PNG 800x800 800x800+0+0 8-bit sRGB 807280B 0.000u 0:00.004
(I have to use readImages because I may process gif image)
Try the following...
std::list<Image> m_images;
// ...
ReadOptions opts;
opts.quiet(true);
Blob src_blob(image.data(), image.length());
readImages(&m_images, src_blob, opts);
Setting ReadOptions.quiet
to true
will suppress any warnings during decoding.
// From `Magick::throwException` method.
if ((quiet_) && (severity < MagickCore::ErrorException))
{
delete nestedException;
return;
}
But if I construct Image like this:
Blob src_blob(image.data(), image.length()); Image image(src_blob);
the codes will work and no throw exception
This is because the constructor-helper method sets quiet
temporarily as a convenience.
// From Image.cpp
Magick::Image::Image(const Blob &blob_)
: _imgRef(new ImageRef)
{
try
{
// Initialize, Allocate and Read images
quiet(true);
read(blob_);
quiet(false);
}
catch (const Error&)
{
// Release resources
delete _imgRef;
throw;
}
}