ns-ext/image.optimize.csx
nsnail de03df1318
Tk (#1)
* <chore>

* 1.0.7

* <adjust>

* <chore>

* <chore>

* <refactor>

* <doc>

* <doc>

* <feat> + Unicode,UnicodeDe

* <revert>

* <fix>

* bugfix

* <feat> 从资源文件读取Description

* <feat> 从资源文件读取Description-可继承

* <fix> 将一个对象序列化成json文本

* <chore>

* 调整一下日志格式

* feat: * 泛型特性本地化资源描述 * 添加测试项目

* <chore>

* feat: enum、string

* feat: long 类型增加rand方法

* feat: ToInvString

* fix: ToInvString

* fix: ToInvString

* fix: ParameterFormat bug

* [BLD] [SKIP CI]
2023-09-28 09:37:45 +08:00

65 lines
1.6 KiB
C#

/*
for %%i in (*.png) do pngquant %%i --force --output %%i --skip-if-larger
for %%i in (*.jpg) do jpegtran -copy none -optimize -perfect %%i %%i
*
*/
var files = Directory
.EnumerateFiles(
"./",
"*.png",
new EnumerationOptions
{
RecurseSubdirectories = true,
AttributesToSkip = FileAttributes.ReparsePoint,
IgnoreInaccessible = true
}
)
.ToArray();
Parallel.ForEach(
files,
file =>
{
var startInfo = new ProcessStartInfo
{
FileName = "pngquant",
Arguments = $"\"{file}\" --force --output \"{file}\" --skip-if-larger"
};
using var p = Process.Start(startInfo);
p.WaitForExit();
Console.WriteLine($"{file}: {p.ExitCode}");
}
);
files = new[] { "*.jpg", "*.jpeg" }
.SelectMany(
x =>
Directory.EnumerateFiles(
"./",
x,
new EnumerationOptions
{
RecurseSubdirectories = true,
AttributesToSkip = FileAttributes.ReparsePoint,
IgnoreInaccessible = true
}
)
)
.ToArray();
Parallel.ForEach(
files,
file =>
{
var startInfo = new ProcessStartInfo
{
FileName = "jpegtran",
Arguments = $"-copy none -optimize -perfect \"{file}\" \"{file}\""
};
using var p = Process.Start(startInfo);
p.WaitForExit();
Console.WriteLine($"{file}: {p.ExitCode}");
}
);