question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Insert Image to Excel returns wrong size

See original GitHub issue

I have an image that has 191x47 pixels. arubaito

    worksheet.addImage(imageID, {
      tl: { col: column, row: row },
      ext: { width: size.width, height: size.height }, // width: 191, height: 47
    });

But when I open excel file, the height was automatically scaled 160%, and 157% with width.

Screen Shot 2019-11-25 at 15 54 10

So how can I insert the original size of an image to excel?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
censys-gitcommented, Aug 19, 2020

If you do any modification to rows or columns, adding an image is like a crap shoot. I have an image that I have modified to be 96 DPI and know the pixel size height and width.

Using ext with height and width results in Excel barfing and having to fix all the images – Drawing at sheet X…

Using tl and br produces an image scaled to 30% because I have the height of the row at 51. Setting the br.row to anything under 0 will reduce to 30%. Setting br.row to 1 or above will scale correctly. Problem is I have an image I want to fit in the row because the bottom of the row has a double border. Setting br.row to 1 overlaps the border (looks like crap). Setting br.row to 0.9999 ends up with a scale of 30% (I’m assuming because the default row height is 15 and the new height is 51 and 15/51 is 0.29999 – guessing.

In any case, addImage is majorly buggy and should be identified as ‘beta’. Certainly not covering some simple conditions of rows and columns.

2reactions
sairamccommented, Feb 10, 2020

We had a similar experience working with the library. When using width and height with tl and br parameters, then width and height are getting ignored.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem size of picture in excel with windows 10 125
I put a picture in excel cell. My picture is a square with 44,46mm in height and width. and 100 % in height...
Read more >
Excel distorts image when printing - TechNet - Microsoft
The issue is that when you place an image in an Excel spreadsheet and then print it (or even print preview it) then...
Read more >
Excel printing and display scaling bug - Microsoft Community
When printing with Excel, the page layout is being affected by display scaling. I had it set at 125%. A spreadsheet that normally...
Read more >
Paste as Picture Link results in distorted picture
Merged cells on the sheet you are pasting the linked picture into may be the culprit. That is what I found helped solve...
Read more >
Shapes/Pictures printing distorted (eg, flattened, squashed
This seems to be a strange Excel bug ("feature"?) ... The point is, you don't want Excel to mess with the image size....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found