Skip to content

Commit 81b93c8

Browse files
authored
Merge pull request #54 from dotnet-campus/t/lindexi/Wmf
Add wmf support
2 parents b19aead + c6cd370 commit 81b93c8

316 files changed

Lines changed: 103902 additions & 98 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/NuGet-tag-publish-MediaConverters.yml

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
- name: Pack MediaConverters.Tool.ContextNuGet
2626
run: dotnet pack --no-build true --configuration Release src\MediaConverters\MediaConverters.Tool.ContextNuGet\MediaConverters.Tool.ContextNuGet.csproj
2727

28+
- name: Pack DotNetCampus.MediaConverter.SkiaWmfRenderer
29+
run: dotnet pack --no-build true --configuration Release src\MediaConverters\SkiaWmfRenderer\src\SkiaWmfRenderer\SkiaWmfRenderer.csproj
30+
2831
- name: Publish and Pack win-x86
2932
run: |
3033
dotnet publish -c Release -r win-x86 src\MediaConverters\MediaConverters.Tool\MediaConverters.Tool.csproj
@@ -69,16 +72,34 @@ jobs:
6972
PackOnLinuxX64:
7073

7174
runs-on: ubuntu-latest
75+
container:
76+
image: debian:buster-slim
7277

7378
steps:
79+
# 由于 Debian 10 (buster) 停止维护了,需要换成 archive.debian.org 源头
80+
- name: UpdateSource
81+
run: |
82+
rm /etc/apt/sources.list
83+
echo 'deb http://archive.debian.org/debian buster main contrib non-free' >> /etc/apt/sources.list
84+
echo 'deb http://archive.debian.org/debian buster-updates main contrib non-free' >> /etc/apt/sources.list
85+
echo 'deb http://archive.debian.org/debian-security buster/updates main contrib non-free' >> /etc/apt/sources.list
86+
- name: InstallTool
87+
run: |
88+
dpkg --add-architecture arm64
89+
apt-get clean
90+
apt-get update
91+
apt-get install libicu-dev -y
92+
apt-get install libssl-dev -y
93+
apt-get install wget -y
94+
apt-get install curl -y
95+
apt-get install clang llvm -y
96+
apt-get install gcc-aarch64-linux-gnu -y
97+
apt-get install binutils-aarch64-linux-gnu -y
98+
apt-get install zlib1g-dev -y
99+
apt-get install zlib1g-dev:arm64 -y
100+
74101
- uses: actions/checkout@v4
75102

76-
- name: Install dotnet tool
77-
run: dotnet tool install -g dotnetCampus.TagToVersion
78-
79-
- name: Set tag to version
80-
run: dotnet TagToVersion -t ${{ github.ref }}
81-
82103
- name: Setup .NET
83104
uses: actions/setup-dotnet@v1
84105
with:
@@ -88,6 +109,15 @@ jobs:
88109
6.0.x
89110
9.0.x
90111
112+
- name: Add .NET global tools to PATH
113+
run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
114+
115+
- name: Install dotnet tool
116+
run: dotnet tool install -g dotnetCampus.TagToVersion
117+
118+
- name: Set tag to version
119+
run: dotnet-TagToVersion -t ${{ github.ref }}
120+
91121
- name: Build with dotnet
92122
run: dotnet build --configuration Release src/MediaConverters/MediaConverters.sln
93123

@@ -104,15 +134,33 @@ jobs:
104134
PackOnLinuxArm64:
105135

106136
runs-on: ubuntu-24.04-arm
137+
container:
138+
image: debian:buster-slim
107139

108140
steps:
109-
- uses: actions/checkout@v4
110-
111-
- name: Install dotnet tool
112-
run: dotnet tool install -g dotnetCampus.TagToVersion
141+
# 由于 Debian 10 (buster) 停止维护了,需要换成 archive.debian.org 源头
142+
- name: UpdateSource
143+
run: |
144+
rm /etc/apt/sources.list
145+
echo 'deb http://archive.debian.org/debian buster main contrib non-free' >> /etc/apt/sources.list
146+
echo 'deb http://archive.debian.org/debian buster-updates main contrib non-free' >> /etc/apt/sources.list
147+
echo 'deb http://archive.debian.org/debian-security buster/updates main contrib non-free' >> /etc/apt/sources.list
148+
- name: InstallTool
149+
run: |
150+
dpkg --add-architecture arm64
151+
apt-get clean
152+
apt-get update
153+
apt-get install libicu-dev -y
154+
apt-get install libssl-dev -y
155+
apt-get install wget -y
156+
apt-get install curl -y
157+
apt-get install clang llvm -y
158+
apt-get install gcc-aarch64-linux-gnu -y
159+
apt-get install binutils-aarch64-linux-gnu -y
160+
apt-get install zlib1g-dev -y
161+
apt-get install zlib1g-dev:arm64 -y
113162
114-
- name: Set tag to version
115-
run: dotnet TagToVersion -t ${{ github.ref }}
163+
- uses: actions/checkout@v4
116164

117165
- name: Setup .NET
118166
uses: actions/setup-dotnet@v1
@@ -123,6 +171,15 @@ jobs:
123171
6.0.x
124172
9.0.x
125173
174+
- name: Add .NET global tools to PATH
175+
run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
176+
177+
- name: Install dotnet tool
178+
run: dotnet tool install -g dotnetCampus.TagToVersion
179+
180+
- name: Set tag to version
181+
run: dotnet-TagToVersion -t ${{ github.ref }}
182+
126183
- name: Build with dotnet
127184
run: dotnet build --configuration Release src/MediaConverters/MediaConverters.sln
128185

Directory.Build.props

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<Project>
2+
23
<Import Project="build\Version.props" />
4+
35
<PropertyGroup>
46
<LangVersion>latest</LangVersion>
57
<PackageOutputPath>$(MSBuildThisFileDirectory)bin\$(Configuration)</PackageOutputPath>
@@ -14,4 +16,9 @@
1416
<Copyright>Copyright © 2020-$([System.DateTime]::Now.ToString(`yyyy`)) dotnet campus, All Rights Reserved.</Copyright>
1517
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1618
</PropertyGroup>
19+
20+
<ItemGroup>
21+
<SourceRoot Include="$(MSBuildThisFileDirectory)"/>
22+
</ItemGroup>
23+
1724
</Project>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# 性能记录
2+
3+
## WMF 图片转换
4+
5+
Commit: e7f9c0adfe736c56e4e0207c15701ccd92b822d1
6+
7+
测试设备:
8+
9+
- CPU: Hygon C86-3G-3G (OPN:3350)
10+
- 系统: Kylin Linux Desktop EDU V10 银河麒麟桌面操作系统(教育版)V10 2403
11+
12+
### 非 AOT 版本
13+
14+
```
15+
lindexi@lindexi-pc:~/lin/sync/lin64$ ./DotNetCampus.MediaConverter
16+
ReadJsonFile Cost 4ms
17+
ParseJsonFile Cost 5ms
18+
Start optimize image file. File='image.wmf' Total Cost 5ms
19+
Copy new file to '/home/lindexi/linux-x64/Test_ldaqazwr.3nx/Copy_1ckqx3ma.hht_image.wmf' Total Cost 183ms
20+
Copy new file Cost 179ms. ImageFile: '/home/lindexi/linux-x64/Test_ldaqazwr.3nx/Copy_1ckqx3ma.hht_image.wmf' Total Cost 183ms
21+
Start convert emf or wmf to png by Inkscape. File='/home/lindexi/linux-x64/Test_ldaqazwr.3nx/Copy_1ckqx3ma.hht_image.wmf' Total Cost 185ms
22+
Convert emf or wmf to svg by Inkscape failed. We will continue use libwmf to convert the image. File='/home/lindexi/linux-x64/Test_ldaqazwr.3nx/Copy_1ckqx3ma.hht_image.wmf' Exception: System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'inkscape' with working directory '/home/lindexi/linux-x64'. No such file or directory
23+
at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
24+
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
25+
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
26+
at DotNetCampus.MediaConverters.Imaging.Optimizations.EnhancedGraphicsMetafileOptimization.ConvertWithInkscape(ImageFileOptimizationContext context)
27+
Total Cost 201ms
28+
ConvertWithInkscape Cost 17ms Total Cost 202ms
29+
ConvertWithInkscapeLibWmf Cost 17ms Total Cost 220ms
30+
Load sk svg Cost 507ms Total Cost 729ms
31+
Save sk svg to png Cost 17ms. OutputFile='/home/lindexi/linux-x64/Test_ldaqazwr.3nx/SVG_gh1sulx2.ezs.png' Total Cost 747ms
32+
Convert svg to png file Cost 527ms. File='/home/lindexi/linux-x64/Test_ldaqazwr.3nx/FixSVG_csmcz2s1.p5b.svg' Total Cost 747ms
33+
ConvertWmfOrEmfToPngFile Cost 564ms. ImageFile: '/home/lindexi/linux-x64/Test_ldaqazwr.3nx/Copy_1ckqx3ma.hht_image.wmf' Total Cost 747ms
34+
Success ConvertWmfOrEmfToPngFile. Update current image file to '/home/lindexi/linux-x64/Test_ldaqazwr.3nx/SVG_gh1sulx2.ezs.png' Total Cost 748ms
35+
Start optimize image with ImageSharp. ImageFile: '/home/lindexi/linux-x64/Test_ldaqazwr.3nx/SVG_gh1sulx2.ezs.png' Total Cost 748ms
36+
Load image with ImageSharp Cost 79ms. ImageFile: '/home/lindexi/linux-x64/Test_ldaqazwr.3nx/SVG_gh1sulx2.ezs.png' Total Cost 827ms
37+
Optimize image with ImageSharp Cost 3ms. ImageFile: '/home/lindexi/linux-x64/Test_ldaqazwr.3nx/SVG_gh1sulx2.ezs.png' Total Cost 831ms
38+
Save optimized image with ImageSharp Cost 63ms. OutputImageFile: '/home/lindexi/linux-x64/Test_ldaqazwr.3nx/kipm4qr5.rav.png' Total Cost 895ms
39+
OptimizeImageFileAsync Cost 895ms. File='/home/lindexi/linux-x64/image.wmf'
40+
Success converted image. Cost 917ms. OutputFile='/home/lindexi/linux-x64/Test_ldaqazwr.3nx/1.png' Total Cost 895ms
41+
```
42+
43+
### AOT 版本
44+
45+
```
46+
lindexi@lindexi-pc:~/lin/sync/lin64$ ./DotNetCampus.MediaConverter
47+
ReadJsonFile Cost 0ms
48+
ParseJsonFile Cost 0ms
49+
Start optimize image file. File='image.wmf' Total Cost 0ms
50+
Check imageFile Exists Cost 0ms. Total Cost 0ms
51+
CreateDirectory workingFolder Cost 0ms. Total Cost 0ms
52+
Copy new file to '/home/lindexi/linux-x64/Test_3udgyrfq.ewe/Copy_cexmekrd.0ne_image.wmf' Total Cost 0ms
53+
Copy new file Cost 0ms. ImageFile: '/home/lindexi/linux-x64/Test_3udgyrfq.ewe/Copy_cexmekrd.0ne_image.wmf' Total Cost 0ms
54+
Start convert emf or wmf to png by Inkscape. File='/home/lindexi/linux-x64/Test_3udgyrfq.ewe/Copy_cexmekrd.0ne_image.wmf' Total Cost 0ms
55+
Convert emf or wmf to svg by Inkscape failed. We will continue use libwmf to convert the image. File='/home/lindexi/linux-x64/Test_3udgyrfq.ewe/Copy_cexmekrd.0ne_image.wmf' Exception: System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'inkscape' with working directory '/home/lindexi/linux-x64'. No such file or directory
56+
at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo, String, String[], String[], String, Boolean, UInt32, UInt32, UInt32[], Int32&, Int32&, Int32&, Boolean, Boolean) + 0x404
57+
at System.Diagnostics.Process.StartCore(ProcessStartInfo) + 0x303
58+
at System.Diagnostics.Process.Start(ProcessStartInfo) + 0x3b
59+
at DotNetCampus.MediaConverters.Imaging.Optimizations.EnhancedGraphicsMetafileOptimization.ConvertWithInkscape(ImageFileOptimizationContext) + 0x1fe
60+
Total Cost 10ms
61+
ConvertWithInkscape Cost 10ms Total Cost 10ms
62+
Run wmf2svg process Cost 173ms Total Cost 184ms
63+
ConvertWithInkscapeLibWmf Cost 174ms Total Cost 184ms
64+
Load sk svg Cost 176ms Total Cost 361ms
65+
Save sk svg to png Cost 11ms. OutputFile='/home/lindexi/linux-x64/Test_3udgyrfq.ewe/SVG_gjvqrzhr.haf.png' Total Cost 373ms
66+
Convert svg to png file Cost 188ms. File='/home/lindexi/linux-x64/Test_3udgyrfq.ewe/FixSVG_ywzqj0xe.b0s.svg' Total Cost 373ms
67+
ConvertWmfOrEmfToPngFile Cost 373ms. ImageFile: '/home/lindexi/linux-x64/Test_3udgyrfq.ewe/Copy_cexmekrd.0ne_image.wmf' Total Cost 373ms
68+
Success ConvertWmfOrEmfToPngFile. Update current image file to '/home/lindexi/linux-x64/Test_3udgyrfq.ewe/SVG_gjvqrzhr.haf.png' Total Cost 373ms
69+
Start optimize image with ImageSharp. ImageFile: '/home/lindexi/linux-x64/Test_3udgyrfq.ewe/SVG_gjvqrzhr.haf.png' Total Cost 373ms
70+
Load image with ImageSharp Cost 1ms. ImageFile: '/home/lindexi/linux-x64/Test_3udgyrfq.ewe/SVG_gjvqrzhr.haf.png' Total Cost 374ms
71+
Optimize image with ImageSharp Cost 0ms. ImageFile: '/home/lindexi/linux-x64/Test_3udgyrfq.ewe/SVG_gjvqrzhr.haf.png' Total Cost 375ms
72+
Save optimized image with ImageSharp Cost 9ms. OutputImageFile: '/home/lindexi/linux-x64/Test_3udgyrfq.ewe/vuwjg5bf.xmt.png' Total Cost 384ms
73+
OptimizeImageFileAsync Cost 384ms. File='/home/lindexi/linux-x64/image.wmf'
74+
Success converted image. Cost 387ms. OutputFile='/home/lindexi/linux-x64/Test_3udgyrfq.ewe/1.png' Total Cost 384ms
75+
```
76+
77+
可见 AOT 的版本只需非 AOT 版本的一半时间

0 commit comments

Comments
 (0)