Wrong picture size?

       int i = sheet.Pictures.Add(5, 6, path);
                Picture pic = sheet.Pictures[i];

                //Set the placement type
                pic.Placement = PlacementType.FreeFloating;

I add picture to excel, all is ok, but next picture will be wrong size in the excel [not actual pix ?]
200X200.jpg (39.7 KB)


I have added this picture to excel worksheet and it displays the size of image as 5.29 cm. The picture has image density of 96 dpi so if you convert centimeter to pixels, you will get the size of picture in excel equivalent to 200, which is fine.

1 inch = 2.54 cm
dpi = 96 px / in
96 px / 2.54 cm

Therefore one centimeter is equal to
1 cm = 96 px / 2.54
1 cm = 37.79527559055118 px

Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

@ahsaniqbalsidiqui , The effect of inserting a picture with the above code is not consistent with the effect of inserting a picture manually in Excel,you can have a try, also I can upload an operation video at next monday

Please feel free to send us the video and we will analyze it to observe the issue to provide our feedback.

NormalTest.zip (2.1 MB)

code and video are upload,
if insert wrong image to excel Manual, it will auto scale to 4%


We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46419 - Wrong picture size


We have noticed that the picture 2222.jpg is very huge. please insert the picture in MS Excel, then check size of the picture , you will find the picture’s size is 200 inches.

int my test, insert this picture in MS Excel will auto scale 4% [may be other images will have different scale] , so can you change default behavior same as MS excel?


We have verified that Excel auto scales it to 4% and have logged this information with the ticket for later reference. We will provide you update after detailed analysis.


If you want to add the picture with scale, please try the following code:

        i = wb.Worksheets[1].Pictures.Add(5, 6, dir + "2222.jpg",4,4);

And you can set the scale with pic.setWidthScale(4)/pic.setHeightScale(4);

Moreover, if you want to set the logical size as the picture’s size, please use the following code:

        Image image = Image.FromFile(dir + "2222.jpg");
       // if (image.HorizontalResolution == 1)
            i = wb.Worksheets[1].Pictures.Add(5, 6, dir + "2222.jpg");
            pic = wb.Worksheets[1].Pictures[i];
            pic.Width = image.Width;
            pic.Height = image.Height;

Hope, this helps.