excelize
excelize copied to clipboard
API AddPicture() cant make image 100% scaling in cell
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.
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}`)
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
Hi, @xuri , Sorry for bothering you. Can you please take a look if you have free.
Thanks for your issue. I think this issue can be related with #212.
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.