Skip to content

Commit fdd8d11

Browse files
committed
Simplified code.
1 parent a524a12 commit fdd8d11

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

src/Magick.NET/ImageOptimizers/ImageOptimizer.cs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
22
// Licensed under the Apache License, Version 2.0.
33

4-
using System.Collections.Generic;
54
using System.Collections.ObjectModel;
65
using System.IO;
6+
using System.Linq;
77
using ImageMagick.ImageOptimizers;
88

99
namespace ImageMagick;
@@ -27,21 +27,6 @@ public sealed class ImageOptimizer
2727
/// </summary>
2828
public bool OptimalCompression { get; set; }
2929

30-
private string SupportedFormats
31-
{
32-
get
33-
{
34-
var formats = new List<string>(_optimizers.Count);
35-
36-
foreach (var optimizer in _optimizers)
37-
{
38-
formats.Add(optimizer.Format.ModuleFormat.ToString());
39-
}
40-
41-
return string.Join(", ", formats.ToArray());
42-
}
43-
}
44-
4530
/// <summary>
4631
/// Performs compression on the specified file. With some formats the image will be decoded
4732
/// and encoded and this will result in a small quality reduction. If the new file size is not
@@ -241,6 +226,7 @@ private bool DoCompress(FileInfo file)
241226
if (IgnoreUnsupportedFormats)
242227
return null;
243228

244-
throw new MagickCorruptImageErrorException("Invalid format, supported formats are: " + SupportedFormats);
229+
var supportedFormats = string.Join(", ", _optimizers.Select(imageOptizimer => imageOptizimer.Format.ModuleFormat.ToString()));
230+
throw new MagickCorruptImageErrorException($"Invalid format, supported formats are: {supportedFormats}");
245231
}
246232
}

0 commit comments

Comments
 (0)