Skip to content

Commit

Permalink
Handle ImageMagick error when copying colored emblems (#2038) #patch
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains authored Jul 5, 2024
1 parent 2517328 commit f2df940
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ImperatorToCK3/Outputter/CoatOfArmsEmblemsOutputter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,16 @@ void CopyEmblem(string emblemFilePath) {
var fileName = CommonFunctions.TrimPath(emblemFilePath);

// Load an image.
var image = new MagickImage(emblemFilePath);
image.Negate(channels: Channels.Red);
MagickImage image;
try {
image = new(emblemFilePath);
image.Negate(channels: Channels.Red);
} catch (Exception ex) {
Logger.Debug($"Exception occurred while loading {emblemFilePath}: {ex}");
Logger.Warn($"Failed to load colored emblem {fileName}. CoAs using this emblem will be broken.");
return;
}

// Write the image to new file.
var outputPath = Path.Combine(outputModPath, "gfx/coat_of_arms/colored_emblems", fileName);
try {
Expand Down

0 comments on commit f2df940

Please sign in to comment.