Hello,
is it possible to read images in a “raw” mode?
Background:
I export images from various manual created excel sheets by using the the PictureCollection from Worksheet.Pictures.
But sometimes MS Excel inserts an image in a lower resolution into an excel sheet but stores the image in the xlsx file in the full resolution. I dont talk about zooming!
This may happen if an image is inserted by the “insert image” menü. The same image inserted via copy and paste from a paint tool leads to an embedded image in full resolution. In both cases the image file inside the xlsx file is stored in full resolution. The difference is in the drawing1.xml which stores an incorrect size as 100% size.
To reproduce the bevahiour, i attached:
1) Original image file “test_image.png”.
2) The excel file “test_image_inserted_by_insert_menu.xlsx” where i inserted the image by insert menu.
3) The excel file “test_image_inserted_by_copy_paste_from_paint.xlsx” where i inserted the image by copy and paste from paint tool.
4) A comparison screenshot “comparison_drawing-xmls.png” of the drawing1.xml files created by excel.
So back to my question. Is it possible to read the image in it’s full resolution how it’s stored inside the xlsx file?
Thanks & Regards…
Hi,
Thanks for your posting and using Aspose.Cells.
We have looked into your issue and found that you can read the raw image using the Picture.Data property.
Please see the following sample code. It reads the raw image from your test_image_inserted_by_insert_menu.xlsx file and it is exactly the same image with 368x565 resolution.
I have attached the output image for your reference. I have tested this issue with the latest version: Aspose.Cells
for .NET v8.4.0.1.
C#
string filePath = @“F:\Shak-Data-RW\Downloads\test_image_inserted_by_insert_menu.xlsx”;
Workbook workbook = new Workbook(filePath);
Worksheet worksheet = workbook.Worksheets[“Tabelle1”];
Picture pic = worksheet.Pictures[0];
File.WriteAllBytes(“output.png”, pic.Data);
Hi Shakeel,
Hi,
Good to know that it sorts our your issue now. Feel free to write back in case you have further comments or questions, we will be happy to assist you soon.
Thank you.