diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-10-16 16:30:11 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-10-16 16:30:11 +0100 |
| commit | 0b6c6de07f9a3aa28c2e8ca8ef30340e3fa1bfc6 (patch) | |
| tree | 075a7a604bbd4e072ec1b07481d4eb82ed7ffd34 /src/lib/image_proxy.cc | |
| parent | 42a122334d594b824c666e5263168386a76801cc (diff) | |
| parent | 016a98b18d01276a1e603885a25785e7389f14d9 (diff) | |
Merge branch 'master' into 12bit
Diffstat (limited to 'src/lib/image_proxy.cc')
| -rw-r--r-- | src/lib/image_proxy.cc | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/lib/image_proxy.cc b/src/lib/image_proxy.cc index ba572c727..3aba6cf7c 100644 --- a/src/lib/image_proxy.cc +++ b/src/lib/image_proxy.cc @@ -32,7 +32,6 @@ using std::cout; using std::string; -using std::stringstream; using boost::shared_ptr; ImageProxy::ImageProxy (shared_ptr<Log> log) @@ -122,10 +121,30 @@ MagickImageProxy::image () const 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 ()); |
