You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 9, 2020. It is now read-only.
When inserting the vector-based image formats WMF or EMF, EPPlus will store the images as PNGs. This is because at some point a call is made to Image.Save() which uses available ImageFormat's in the GDI. These do NOT include WMF or EMF so Image.Save() falls back to using the one for PNG.
The end result would be pixelation when stretched inside excel as well as a larger file size. Running this in DrawingTests.cs:
[TestMethod]
public void AddPicture_Wmf_StoresFormat()
{
AddPicture_Assert("Vector Drawing.wmf", ImageFormat.Wmf);
}
public void AddPicture_Assert(string fileName, ImageFormat format)
{
using (var pck = new ExcelPackage())
{
var workbook = pck.Workbook;
var ws = workbook.Worksheets.Add("Sheet1");
var pic = ws.Drawings.AddPicture("Pic4", new FileInfo(Path.Combine(_clipartPath, fileName)));
pic.From.Row = 0;
pic.From.Column = 0;
pic.To.Row = 30;
pic.To.Column = 23;
using (var zip = new ZipArchive(new MemoryStream(pck.GetAsByteArray()), ZipArchiveMode.Read))
{
var found = false;
foreach (var entry in zip.Entries)
{
if (entry.Name != $"1{fileName}")
continue;
found = true;
var stream = entry.Open();
var drawing = Image.FromStream(stream);
Assert.AreEqual(format, drawing.RawFormat);
}
Assert.IsTrue(found, "Image was not found in zip.");
}
}
}
The GUID listed is for PNG. To fix, the existing FileStream should be used.
Here is a PR with the proposed changes which will allow the 7 new tests (including the one above) to pass: #490
The text was updated successfully, but these errors were encountered:
aesalazar
changed the title
WMF and EMF being converted to PNG In ExcelPicture
WMF and EMF being converted to PNG In ExcelPicture for PR #490
Jun 27, 2019
Thanks for your detailed description. I have fixed the underlaying problem in EPPlus version 5. I could sadly not use the PR, but the functionality is the same. In version 5 I have rewritten the image handling with a package common picture store.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When inserting the vector-based image formats WMF or EMF, EPPlus will store the images as PNGs. This is because at some point a call is made to
Image.Save()
which uses availableImageFormat
's in the GDI. These do NOT include WMF or EMF soImage.Save()
falls back to using the one for PNG.The end result would be pixelation when stretched inside excel as well as a larger file size. Running this in
DrawingTests.cs
:Gives this result:
The GUID listed is for PNG. To fix, the existing
FileStream
should be used.Here is a PR with the proposed changes which will allow the 7 new tests (including the one above) to pass: #490
The text was updated successfully, but these errors were encountered: