🐛 优化代码
This commit is contained in:
@@ -203,6 +203,9 @@ namespace GeekDesk.Util
|
|||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
FileInfo file = new FileInfo(filePath);
|
||||||
|
if (file.Exists && file.Length > 0)
|
||||||
{
|
{
|
||||||
Image img = Image.FromFile(filePath);
|
Image img = Image.FromFile(filePath);
|
||||||
if (img.Width <= tWidth && img.Height <= tHeight)
|
if (img.Width <= tWidth && img.Height <= tHeight)
|
||||||
@@ -247,6 +250,10 @@ namespace GeekDesk.Util
|
|||||||
File.Delete(tempPath);
|
File.Delete(tempPath);
|
||||||
return bm;
|
return bm;
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
return Base64ToBitmapImage(Constants.DEFAULT_IMG_IMAGE_BASE64);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -364,6 +371,9 @@ namespace GeekDesk.Util
|
|||||||
public static bool IsImage(string path)
|
public static bool IsImage(string path)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
string ext = Path.GetExtension(path);
|
||||||
|
if (!string.IsNullOrEmpty(ext))
|
||||||
{
|
{
|
||||||
string strExt = Path.GetExtension(path).Substring(1);
|
string strExt = Path.GetExtension(path).Substring(1);
|
||||||
string suffixs = "bmp,jpg,png,tif,gif,pcx,tga,exif,fpx,svg,psd,cdr,pcd,dxf,ufo,eps,ai,raw,WMF,webp,avif";
|
string suffixs = "bmp,jpg,png,tif,gif,pcx,tga,exif,fpx,svg,psd,cdr,pcd,dxf,ufo,eps,ai,raw,WMF,webp,avif";
|
||||||
@@ -375,6 +385,7 @@ namespace GeekDesk.Util
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
|||||||
Reference in New Issue
Block a user