Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ private static EnhancedGraphicsMetafileOptimizationResult ConvertWithLibWmf(in E
return EnhancedGraphicsMetafileOptimizationResult.NotSupported();
}

/// <summary>
/// 是否 Inkscape 应用程序未安装
/// </summary>
/// 先不考虑后续 Inkscape 可能安装的问题。可在业务端设置为 false 继续尝试
public static bool IsInkscapeNotBeInstalled { get; set; }

[SupportedOSPlatform("linux")]
private static EnhancedGraphicsMetafileOptimizationResult ConvertWithInkscape(EnhancedGraphicsMetafileOptimizationContext context)
{
Expand All @@ -301,6 +307,13 @@ private static EnhancedGraphicsMetafileOptimizationResult ConvertWithInkscape(En

context.LogMessage($"Start convert emf or wmf to png by Inkscape. File:'{file}'");

if (IsInkscapeNotBeInstalled)
{
// 转换失败,因为缓存的属性明确表示 Inkscape 应用程序不存在
context.LogMessage($"Convert emf or wmf to svg by Inkscape failed. Because cache property indicate Inkscape application not be installed. {nameof(IsInkscapeNotBeInstalled)}=true. We will continue use libwmf to convert the image.");
return EnhancedGraphicsMetafileOptimizationResult.NotSupported();
}

var processStartInfo = new ProcessStartInfo("inkscape")
{
ArgumentList =
Expand Down Expand Up @@ -336,6 +349,9 @@ private static EnhancedGraphicsMetafileOptimizationResult ConvertWithInkscape(En
// 明确不存在,那就不记录错误信息了
// 大概耗时 17 毫秒
context.LogMessage($"Convert emf or wmf to svg by Inkscape failed. Because not found Inkscape application. Please make sure Inkscape be installed. We will continue use libwmf to convert the image.");

// 设置为 true 缓存,避免下次继续尝试
IsInkscapeNotBeInstalled = true;
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SkiaSharp" Version="3.119.0" />
<PackageReference Include="SkiaSharp" Version="3.116.1" />

<PackageReference Include="Svg.Skia" Version="3.0.4" />
<PackageReference Include="System.Drawing.Common" Version="9.0.7" />

<PackageReference Include="HarfBuzzSharp" Version="8.3.1.1" />
<PackageReference Include="HarfBuzzSharp.NativeAssets.Linux" Version="8.3.1.1" />

<!-- System.Text.Encoding.CodePages 库被用在 Encoding.RegisterProvider 处理大量特殊编码 -->
<PackageReference Include="System.Text.Encoding.CodePages" Version="9.0.7" />
Expand Down
Loading