移动端检查修改

This commit is contained in:
geh
2025-09-16 10:56:03 +08:00
parent 19ea2f2363
commit bf9f9c44b5
10 changed files with 109 additions and 55 deletions
@@ -61,48 +61,57 @@ namespace WebAPI.Controllers
if (extensionstr==".jpg" || extensionstr == ".gif" || extensionstr == ".bmp" || extensionstr == ".png")
{
string TakePicDateTime = string.Empty;
System.Drawing.Image image = System.Drawing.Image.FromStream(file.InputStream, true, false);
Encoding ascii = Encoding.ASCII;
//遍历图像文件元数据,检索所有属性
foreach (System.Drawing.Imaging.PropertyItem p in image.PropertyItems)
//人员入场忽略签字时的时间水印
if (typeName != "PersonSign")
{
//如果是PropertyTagDateTime,则返回该属性所对应的值
if (p.Id == 0x0132)
string TakePicDateTime = string.Empty;
System.Drawing.Image image = System.Drawing.Image.FromStream(file.InputStream, true, false);
Encoding ascii = Encoding.ASCII;
//遍历图像文件元数据,检索所有属性
foreach (System.Drawing.Imaging.PropertyItem p in image.PropertyItems)
{
TakePicDateTime = ascii.GetString(p.Value);
}
}
TakePicDateTime = string.IsNullOrEmpty(TakePicDateTime) ? string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now) : TakePicDateTime;
if (!string.IsNullOrEmpty(TakePicDateTime))
{
////获取元数据中的拍照日期时间,以字符串形式保存
//TakePicDateTime = GetTakePicDateTime(pi);
//分析字符串分别保存拍照日期和时间的标准格式
var SpaceLocation = TakePicDateTime.IndexOf(" ");
var dt = TakePicDateTime.Substring(0, SpaceLocation);
dt = dt.Replace(":", "-");
var tm = TakePicDateTime.Substring(SpaceLocation + 1, TakePicDateTime.Length - SpaceLocation - 2);
TakePicDateTime = dt + " " + tm;
//由列表中的文件创建内存位图对象
var Pic = new Bitmap(rootUrl);
//由位图对象创建Graphics对象的实例
var g = Graphics.FromImage(Pic);
Font ft = new Font("宋体", 20, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134)));//定义字体
//在Graphics表面绘制数码照片的日期/时间戳
g.DrawString(TakePicDateTime, ft, Brushes.Gold, 0, Pic.Height - 100);
// - 50);
string newRoot = localRoot + "newfile/";
if (!Directory.Exists(newRoot))
{
Directory.CreateDirectory(newRoot);
//如果是PropertyTagDateTime,则返回该属性所对应的值
if (p.Id == 0x0132)
{
TakePicDateTime = ascii.GetString(p.Value);
}
}
//将添加日期/时间戳后的图像进行保存
Pic.Save(newRoot + fileName);
fileName = "newfile/" + fileName;
//释放内存位图对象
Pic.Dispose();
TakePicDateTime = string.IsNullOrEmpty(TakePicDateTime)
? string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now)
: TakePicDateTime;
if (!string.IsNullOrEmpty(TakePicDateTime))
{
////获取元数据中的拍照日期时间,以字符串形式保存
//TakePicDateTime = GetTakePicDateTime(pi);
//分析字符串分别保存拍照日期和时间的标准格式
var SpaceLocation = TakePicDateTime.IndexOf(" ");
var dt = TakePicDateTime.Substring(0, SpaceLocation);
dt = dt.Replace(":", "-");
var tm = TakePicDateTime.Substring(SpaceLocation + 1,
TakePicDateTime.Length - SpaceLocation - 2);
TakePicDateTime = dt + " " + tm;
//由列表中的文件创建内存位图对象
var Pic = new Bitmap(rootUrl);
//由位图对象创建Graphics对象的实例
var g = Graphics.FromImage(Pic);
Font ft = new Font("宋体", 20, FontStyle.Regular, GraphicsUnit.Point,
((byte)(134))); //定义字体
//在Graphics表面绘制数码照片的日期/时间戳
g.DrawString(TakePicDateTime, ft, Brushes.Gold, 0, Pic.Height - 100);
// - 50);
string newRoot = localRoot + "newfile/";
if (!Directory.Exists(newRoot))
{
Directory.CreateDirectory(newRoot);
}
//将添加日期/时间戳后的图像进行保存
Pic.Save(newRoot + fileName);
fileName = "newfile/" + fileName;
//释放内存位图对象
Pic.Dispose();
}
}
}