Skip to content

Commit 45251a1

Browse files
authored
Merge pull request #602 from Kanglt/master
修复Excel导出图片慢的问题
2 parents 20c93db + 68dedf5 commit 45251a1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Magicodes.ExporterAndImporter.Excel/Images/ImageExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public static Image GetImageByUrl(this string url, out IImageFormat format)
5656
var image = Image.Load(memoryStream);
5757
format = image.GetImageFormat(memoryStream);
5858

59-
if (image.Metadata.HorizontalResolution == 0 && image.Metadata.VerticalResolution == 0)
59+
// 2025-08-03 SixLabors.ImageSharp在加载某些格式的图片(尤其是 JPEG/PNG)时,如果图片元数据中没有明确指定 DPI 信息,或者元数据格式不符合预期,可能会将 DPI 默认设置为 1
60+
if (image.Metadata.HorizontalResolution <= 1 && image.Metadata.VerticalResolution <= 1)
6061
{
6162
image.Metadata.HorizontalResolution = ImageMetadata.DefaultHorizontalResolution;
6263
image.Metadata.VerticalResolution = ImageMetadata.DefaultVerticalResolution;

0 commit comments

Comments
 (0)