LOG_TIMING ("[%1] MagickImageProxy begins decode and convert of %2 bytes", boost::this_thread::get_id(), _blob.length());
Magick::Image* magick_image = 0;
+ string error;
try {
magick_image = new Magick::Image (_blob);
- } catch (...) {
- throw DecodeError (_("Could not decode image file"));
+ } catch (Magick::Exception& e) {
+ error = e.what ();
+ }
+
+ if (!magick_image) {
+ /* ImageMagick cannot auto-detect Targa files, it seems, so try here with an
+ explicit format. I can't find it documented that passing a (0, 0) geometry
+ is allowed, but it seems to work.
+ */
+ try {
+ magick_image = new Magick::Image (_blob, Magick::Geometry (0, 0), "TGA");
+ } catch (...) {
+
+ }
+ }
+
+ if (!magick_image) {
+ /* If we failed both an auto-detect and a forced-Targa we give the error from
+ the auto-detect.
+ */
+ throw DecodeError (String::compose (_("Could not decode image file (%1)"), error));
}
LOG_TIMING ("[%1] MagickImageProxy decode finished", boost::this_thread::get_id ());
/* Write line-by-line here as _image must be aligned, and write() cannot be told about strides */
uint8_t* p = _image->data()[0];
for (int i = 0; i < size.height; ++i) {
+#ifdef DCPOMATIC_IMAGE_MAGICK
using namespace MagickCore;
+#else
+ using namespace MagickLib;
+#endif
magick_image->write (0, i, size.width, 1, "RGB", CharPixel, p);
p += _image->stride()[0];
}