summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-09-08 22:09:15 +0100
committerCarl Hetherington <cth@carlh.net>2014-09-08 22:09:15 +0100
commitac2001e6f9b9095f6fc448227a734580480bc02c (patch)
tree8d1670c31d67ab9a4edc1b585aa5a0e91050bdb0 /src
parent991cb7044ecff299f893a995abc090e253f854f7 (diff)
Fix Targa file loading.
Diffstat (limited to 'src')
-rw-r--r--src/lib/image_proxy.cc24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/lib/image_proxy.cc b/src/lib/image_proxy.cc
index 7c212be04..3aba6cf7c 100644
--- a/src/lib/image_proxy.cc
+++ b/src/lib/image_proxy.cc
@@ -121,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 ());