-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ws.Drawings.AddPicture don't support jpeg/exif #645
Comments
I'll have a look. Can you attach a failing image? |
open with UltraEdit |
Thanks. The GenericImageReader seems to fail on this image. The TIFF header is correctly read, but it fails in a later stage and causes an exception. I'll investigate and provide a fix shortly. I assume you use a non-GDI environment as this works in Windows and Linux with libgdiplus with the package.Settings.ImageSettings.PrimaryImageHandler = new SystemDrawingImageHandler(); |
I have applied a fix for this issue. The internal jpg reader seems to get out of sync after reading the App0 header. Feel free to try it using our develop nuget feed ... https://github.com/EPPlusSoftware/EPPlus/wiki/Using-our-Develop-Nuget-Feed |
This is fixed in version 5.8.11 and 6.0.5 |
i use epplus 6.0.4 export excel with image
var imageInfo = new FileInfo(localImageFileName);
picture = ws.Drawings.AddPicture($"image_{DateTime.Now.Ticks}", imageInfo);
then thrown exception:
System.InvalidOperationException: No image handler for image type Jpg
then i change my code
FileStream fileStream = new FileStream(localImageFileName, FileMode.Open, FileAccess.Read);
byte[] buffer = new byte[4];
fileStream.Read(buffer, 0, 4);
string magicNumberMapping = string.Join("", buffer.Select(element => element.ToString("X2")));
fileStream.Seek(0, SeekOrigin.Begin);
picture = ws.Drawings.AddPicture($"image_{DateTime.Now.Ticks}", fileStream, ePictureType.Jpg);
then find those images of thrown exception magicNumberMapping is 'FFD8FFE1', work fine magicNumberMapping is 'FFD8FFE0'
FFD8FFE0(JPEG/JFIF),FFD8FFE1(JPEG/EXIF)
The text was updated successfully, but these errors were encountered: