d2phap/ImageGlass · warning · NotSupportedException
IGE_002
IGE_002
Error message
IGE_002: Unsupported image format.
What it means
Thrown by MagickCodec.LosslessCompress when Magick.NET's ImageOptimizer does not support the file. ImageOptimizer only losslessly rewrites a small set of formats (primarily JPEG and PNG); IsSupported returns false for everything else and the method throws NotSupportedException tagged IGE_002. A null/blank path returns false earlier instead of throwing.
Source
Thrown at source/ImageGlass.Lib/Common/Photoing/Codecs/MagickCodecs/MagickCodec.cs:1284
/// <summary>
/// Performs lossless compression on the specified file using Magick.NET.
/// If the new file size is not smaller, the file won't be overwritten.
/// </summary>
/// <returns>True when the image could be compressed otherwise false.</returns>
/// <exception cref="NotSupportedException"></exception>
public static bool LosslessCompress(string? filePath)
{
if (string.IsNullOrWhiteSpace(filePath)) return false;
var fi = new FileInfo(filePath);
var opt = new ImageOptimizer()
{
OptimalCompression = true,
};
// check if the format is supported
if (!opt.IsSupported(fi)) throw new NotSupportedException("IGE_002: Unsupported image format.");
return opt.LosslessCompress(fi);
}
}
View on GitHub (pinned to 4a3c4fecef)
Solutions
- Pre-check support the same way the method does: if (new ImageOptimizer().IsSupported(new FileInfo(path))) before calling, and skip otherwise.
- Filter batch inputs to JPEG/PNG before invoking LosslessCompress.
- Wrap the call in try/catch (NotSupportedException) and continue the batch instead of aborting.
- For unsupported formats, fall back to a lossy re-encode via MagickCodec.SaveAsync if compression is mandatory.
Example fix
// before
MagickCodec.LosslessCompress(filePath);
// after
var opt = new ImageOptimizer { OptimalCompression = true };
if (opt.IsSupported(new FileInfo(filePath)))
{
MagickCodec.LosslessCompress(filePath);
} Defensive patterns
Strategy: validation
Validate before calling
var fi = new FileInfo(filePath);
var supported = new ImageOptimizer { OptimalCompression = true }.IsSupported(fi);
if (!supported) return; // skip silently Try / catch
try { MagickCodec.LosslessCompress(filePath); }
catch (NotSupportedException ex) when (ex.Message.Contains("IGE_002"))
{ /* skip unsupported file in a batch */ } Prevention
- Pre-filter batch inputs to JPEG/PNG, the formats ImageOptimizer supports.
- Mirror the IsSupported check the method uses before calling.
- Treat NotSupported as 'skip and continue' in batch tools, not as fatal.
When it happens
Trigger: Calling LosslessCompress on a GIF, WEBP, BMP, TIFF, HEIC, RAW, SVG, or any format outside the optimizer's supported set; running the built-in LosslessCompression tool on a mixed batch without filtering.
Common situations: Batch compression tool invoked on a folder containing animation/image formats the optimizer cannot touch; user expects 'lossless compress' to apply to every image type; plugin-owned format passed to the built-in compressor.
Related errors
- The base64 content is invalid.
- IGE: Unsupported image format.
- IGE: Unsupported image format.
- IGE_002
- IGE: '{codec.CodecName}' could not write the image. {result.
AI-assisted analysis of d2phap/ImageGlass@4a3c4fecef (2026-08-13).
Data as JSON: /api/errors/1d30166a60dcb82d.
Report an issue: GitHub.