資源簡介
可以批量轉換JPG的尺寸和壓縮的質量
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
using?System.Drawing.Imaging;
using?System.IO;
?
namespace?JpgBatchConvert
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????maxValue.KeyPress?+=?tbox_KeyPress_Number;
????????}
????????private?async?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????if?(dirPath.Text?==?““)
????????????{
????????????????MessageBox.Show(“請輸入文件夾地址“);
????????????????return;
????????????}
????????????if?(!Directory.Exists(dirPath.Text))
????????????{
????????????????MessageBox.Show(“文件夾地址不存在“);
????????????????return;
????????????}
????????????if?(maxValue.Text?==?““)
????????????{
????????????????MessageBox.Show(“高寬“);
????????????????return;
????????????}
????????????button1.Enabled?=?false;
????????????button1.Text?=?“轉換中...“;
????????????await?StartConvert();
????????????textBox1.Text?=?Global.ErrorFIle;
????????????Global.ErrorFIle?=?““;
????????????MessageBox.Show(“全部轉換成功“);
????????????button1.Enabled?=?true;
????????????button1.Text?=?“開始轉換“;
????????}
????????private?Task?StartConvert()
????????{
????????????int?maxSize?=?int.Parse(maxValue.Text);
????????????int?jpgQuality?=?Convert.ToInt16(quality.Value);
????????????Process?process?=?new?Process();
????????????IProgress?progress?=?new?Progress((progressValue)?=>?{?label5.Text?=“轉換完成:“?+?progressValue.ToString();?});
????????????string?LeftOrRight?=?“Right“;
????????????if(radioButton2.Checked)
????????????????LeftOrRight?=?“Left“;
????????????return?Task.Run(()?=>?process.batchConvert(progressmaxSizejpgQualitydirPath.Text?checkBox1.Checked?LeftOrRight));
????????}
????????public?static?void?tbox_KeyPress_Number(object?sender?System.Windows.Forms.KeyPressEventArgs?e)
????????{
????????????//數值輸入控制:只能輸入數字,點和回車
????????????if?(!(char.IsNumber(e.KeyChar))?&&?e.KeyChar?!=?(char)13?&&?e.KeyChar?!=?(char)8?)
????????????????e.Handled?=?true;
????????}
????????
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2020-02-27?15:29??JpgBatchConvert\
?????目錄???????????0??2020-02-27?15:29??JpgBatchConvert\.vs\
?????目錄???????????0??2020-02-27?15:29??JpgBatchConvert\.vs\JpgBatchConvert\
?????目錄???????????0??2020-02-27?15:29??JpgBatchConvert\.vs\JpgBatchConvert\v14\
?????文件???????49664??2016-11-16?21:28??JpgBatchConvert\.vs\JpgBatchConvert\v14\.suo
?????目錄???????????0??2020-02-27?15:29??JpgBatchConvert\.vs\JpgBatchConvert\v15\
?????文件???????53248??2020-01-05?16:09??JpgBatchConvert\.vs\JpgBatchConvert\v15\.suo
?????目錄???????????0??2020-02-27?15:29??JpgBatchConvert\.vs\JpgBatchConvert\v15\Server\
?????目錄???????????0??2020-02-27?15:29??JpgBatchConvert\.vs\JpgBatchConvert\v15\Server\sqlite3\
?????文件???????????0??2019-04-20?19:10??JpgBatchConvert\.vs\JpgBatchConvert\v15\Server\sqlite3\db.lock
?????文件??????581632??2020-01-05?16:09??JpgBatchConvert\.vs\JpgBatchConvert\v15\Server\sqlite3\storage.ide
?????目錄???????????0??2020-02-27?15:29??JpgBatchConvert\JpgBatchConvert\
?????文件?????????184??2018-01-23?08:35??JpgBatchConvert\JpgBatchConvert\App.config
?????目錄???????????0??2020-02-27?15:29??JpgBatchConvert\JpgBatchConvert\bin\
?????目錄???????????0??2020-02-27?15:29??JpgBatchConvert\JpgBatchConvert\bin\Debug\
?????文件??????207360??2020-01-05?15:59??JpgBatchConvert\JpgBatchConvert\bin\Debug\JpgBatchConvert.exe
?????文件?????????184??2018-01-23?08:35??JpgBatchConvert\JpgBatchConvert\bin\Debug\JpgBatchConvert.exe.config
?????文件???????34304??2020-01-05?15:59??JpgBatchConvert\JpgBatchConvert\bin\Debug\JpgBatchConvert.pdb
?????文件???????24216??2018-01-23?08:58??JpgBatchConvert\JpgBatchConvert\bin\Debug\JpgBatchConvert.vshost.exe
?????文件?????????184??2018-01-23?08:35??JpgBatchConvert\JpgBatchConvert\bin\Debug\JpgBatchConvert.vshost.exe.config
?????文件?????????490??2013-03-18?17:00??JpgBatchConvert\JpgBatchConvert\bin\Debug\JpgBatchConvert.vshost.exe.manifest
?????目錄???????????0??2016-04-27?09:33??JpgBatchConvert\JpgBatchConvert\bin\Release\
?????文件????????2440??2020-01-05?15:59??JpgBatchConvert\JpgBatchConvert\Form1.cs
?????文件???????11010??2020-01-05?15:58??JpgBatchConvert\JpgBatchConvert\Form1.Designer.cs
?????文件??????147455??2020-01-05?15:58??JpgBatchConvert\JpgBatchConvert\Form1.resx
?????文件?????????245??2019-04-20?19:14??JpgBatchConvert\JpgBatchConvert\Global.cs
?????文件????????3461??2020-01-05?15:56??JpgBatchConvert\JpgBatchConvert\JPG.cs
?????文件????????4254??2019-04-20?19:16??JpgBatchConvert\JpgBatchConvert\JpgBatchConvert.csproj
?????目錄???????????0??2020-02-27?15:29??JpgBatchConvert\JpgBatchConvert\obj\
?????目錄???????????0??2020-02-27?15:29??JpgBatchConvert\JpgBatchConvert\obj\Debug\
?????文件????????1452??2020-01-05?15:53??JpgBatchConvert\JpgBatchConvert\obj\Debug\DesignTimeResolveAssemblyReferences.cache
............此處省略25個文件信息
評論
共有 條評論