Skip to content
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

API AddPicture() cant make image 100% scaling in cell #248

Closed
zedlee opened this issue Jul 11, 2018 · 3 comments
Closed

API AddPicture() cant make image 100% scaling in cell #248

zedlee opened this issue Jul 11, 2018 · 3 comments

Comments

@zedlee
Copy link

zedlee commented Jul 11, 2018

Description
I wanna insert an image and make it 100% scaling base on the height of the cell. But it didn't work whatever I adjust the parameter "format".

I try the parameters below
err := xl.xlsxFile.AddPicture(sheetName, cellIndex, imgPath, `{"y_scale": 1.00}`)
or
err := xl.xlsxFile.AddPicture(sheetName, cellIndex, imgPath, `{"positioning": "oneCell"}`)
But it turned out the image far exceed the height of cell.
image

Curiously. If I set y_scale to 0.99, the image could scaling in the cell to most extent. And we can see, there is a little bit margin lies in the bottom of cell.
e.g. err := xl.xlsxFile.AddPicture(sheetName, cellIndex, imgPath, `{"y_scale": 0.99}`)
image

Output of go version:

$ go version
go version go1.10.1 linux/amd64

Excelize version or commit ID:

$ git rev-parse HEAD
9cb0e9308b7e65d5a277b0c6af9fa0e8680b3658

Environment details (OS, Microsoft Excel™ version, physical, etc.):

$ uname -a
Linux kvm-CcNgxVcard-3031 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/issue
CentOS release 6.4 (Final)
Kernel \r on an \m

I don't know If I did anything wrong? or there has a bug lies in the code.
Many thanks and look forward to your reply

@zedlee
Copy link
Author

zedlee commented Jul 19, 2018

Hi, @xuri , Sorry for bothering you. Can you please take a look if you have free.

@xuri
Copy link
Member

xuri commented Jul 19, 2018

Thanks for your issue. I think this issue can be related with #212.

@xuri xuri mentioned this issue May 8, 2022
@xuri
Copy link
Member

xuri commented May 23, 2023

Sorry for the late reply. I changed the default point to the pixels conversion factor for a better scale effect in the commit a246db6. Please upgrade to the master branch code, and this patch will be released in the next version. Related to my replies in issues #569 and #1536, the image scaling depends on each row's height and column's width. For these storage inner workbook files with pt units, we need to convert them into pixels, since this conversion was affected by device DPI, so we can't be made the conversion result fit any devices. As you open the same workbook with an image in a different spreadsheet application, operation system, or client device, the size of an image may be different, so please adjust the scale by image options as you need. I closed this issue, if you have any feedback please let me know, and reopen this any time.

@xuri xuri closed this as completed May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants