# HG changeset patch # User Carnë Draug # Date 1378329668 -3600 # Node ID 8508b8ae46a8aa450b129cdced79c116384031d4 # Parent 63b53ea33a8b7a3de4c087e766fc6db50644a8d8 imread: fix identification of PNG files as indexed. * __magick_read__.cc (is_indexed): expand extra check for PNG files by confirming value in color_type_orig. (get_depth): only fix indentification as binary for depth of 8. When Magick reports different than 1 for binary images, seems to always change it for 8, not anything else different than 1. diff -r 63b53ea33a8b -r 8508b8ae46a8 libinterp/dldfcn/__magick_read__.cc --- a/libinterp/dldfcn/__magick_read__.cc Wed Sep 04 21:22:43 2013 +0100 +++ b/libinterp/dldfcn/__magick_read__.cc Wed Sep 04 22:21:08 2013 +0100 @@ -71,12 +71,17 @@ // 1) A grayscale jpeg image can report being indexed even though the // JPEG format has no support for indexed images. We can at least // fix this one. +// 2) A PNG file is only an indexed image if color type orig is 3 (value comes +// from libpng) static bool is_indexed (const Magick::Image& img) { bool retval = false; - - if (img.classType () == Magick::PseudoClass && img.magick () != "JPEG") + const std::string format = img.magick (); + if (img.classType () == Magick::PseudoClass + && format != "JPEG" + && (format != "PNG" + || const_cast (img).attribute ("PNG:IHDR.color-type-orig") == "3")) retval = true; return retval; @@ -101,7 +106,7 @@ get_depth (Magick::Image& img) { octave_idx_type depth = img.depth (); - if (depth != 1 + if (depth == 8 && img.channelDepth (Magick::RedChannel) == 1 && img.channelDepth (Magick::CyanChannel) == 1 && img.channelDepth (Magick::OpacityChannel) == 1