QL-Win/QuickLook · error · NotSupportedException

No icons in ICNS file

Error message

No icons in ICNS file

What it means

Thrown by IcnsDecoder.GetImage(Stream) after ReadImage and DecodeAllImages when the result array is empty (result.Length <= 0). It means the ICNS container was readable but contained zero decodable icons, so there is nothing to display. NotSupportedException signals an effectively empty/iconless ICNS.

Source

Thrown at QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/IcnsProvider.cs:560

        IcnsElement[] icnsElements = new IcnsElement[icnsElementList.Count];
        for (int i = 0; i < icnsElements.Length; i++)
            icnsElements[i] = icnsElementList[i];

        return icnsElements;
    }

    public static IcnsImage GetImage(string filename)
    {
        using (var stream = new FileStream(filename, FileMode.Open))
            return GetImage(stream);
    }

    public static IcnsImage GetImage(Stream stream)
    {
        IcnsElement[] icnsContents = ReadImage(stream);
        IcnsImage[] result = IcnsDecoder.DecodeAllImages(icnsContents);
        if (result.Length <= 0)
            throw new NotSupportedException("No icons in ICNS file");

        IcnsImage max = null;
        foreach (IcnsImage bitmap in result)
            if (bitmap.Bitmap != null && (max == null || (bitmap.Bitmap.Width > bitmap.Bitmap.Height)))
                max = bitmap;

        return max;
    }

    public static IcnsImage[] GetImages(string filename)
    {
        using (var stream = new FileStream(filename, FileMode.Open))
            return GetImages(stream);
    }

    public static IcnsImage[] GetImages(Stream stream)
    {
        IcnsElement[] icnsContents = ReadImage(stream);

View on GitHub (pinned to cb5d9c429c)

Solutions

  1. Inspect DecodeAllImages to see whether icons are being skipped (unsupported type) vs. truly absent; if skipped, add support for those type codes.
  2. Open the ICNS in a known-good viewer (Preview/macOS Finder); if it also shows nothing, the file is empty.
  3. Re-generate the ICNS from source images with iconutil so it contains standard icon entries.
  4. Catch NotSupportedException at the plugin boundary and report 'no icons found' gracefully.

Example fix

// before
IcnsImage[] result = IcnsDecoder.DecodeAllImages(icnsContents);
if (result.Length <= 0)
    throw new NotSupportedException("No icons in ICNS file");

// after — surface a typed, recoverable result
if (result.Length <= 0)
    return null; // caller decides how to present 'empty icon set'
Defensive patterns

Strategy: validation

Validate before calling

var images = IcnsDecoder.DecodeAllImages(icnsContents);
if (images.Length == 0) { /* report 'no decodable icons', don't call GetImage's throw path */ }

Try / catch

try { var img = IcnsDecoder.GetImage(stream); }
catch (NotSupportedException ex) when (ex.Message.Contains("No icons")) { /* empty ICNS */ }

Prevention

When it happens

Trigger: ReadImage returns elements, but DecodeAllImages skips/throws on every one (e.g. all entries are unsupported types caught internally, or all decode failures were swallowed), yielding an empty list; or the file parsed as ICNS but had no icon elements at all.

Common situations: An ICNS that lists only icon type codes this decoder cannot handle; a file with a valid 'icns' header but no 'icon' sub-elements; all icons discarded during decoding due to upstream exceptions.

Related errors


AI-assisted analysis of QL-Win/QuickLook@cb5d9c429c (2026-08-13). Data as JSON: /api/errors/b9fb35a6573a26d3. Report an issue: GitHub.