Skip to content

New ImagePart media added with extension .bin  #1488

Closed
@psyvision

Description

@psyvision

Describe the bug

This is a follow up to an original bug #1305 "New ImagePart is created as .bin instead of real extension" which is still an issue with the most recent 2.20.0 release.

When adding a new ImagePart the media in the bundled package has an extension of .bin instead of .jpg etc.

Screenshots
If applicable, add screenshots to help explain your problem.

To Reproduce

Create a new document and add an ImagePart using the following code:

// Load an image and get the appropriate mime type
var image = System.Drawing.Image.LoadFromFile("myphoto.jpg");
var codes = ImageCodecInfo.GetImageDecoders();
var mimeType = codes.First(c => c.FormatID == image.RawFormat.Guid).MimeType;

var imagePart = mainPart.AddImagePart(mimeType); // image/jpeg

using var stream = new MemoryStream();
image.Save(stream, image.RawFormat);
stream.Position = 0;
imagePart.FeedData(stream);

Observed behavior
The media is added to the word document package with .bin extension

Expected behavior
The media is added to the word document package with .jpg extension

Desktop (please complete the following information):

  • OS: Windows 10
  • Office version: 2306 - 16529.20154
  • .NET Target: .NET Core 6
  • DocumentFormat.OpenXml Version: 2.20.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions