-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
AddPicture Method: Identifying Scale Adjustment Direction and Proposing Enhanced Functionality #1813
Comments
Thanks for your issue. If you specify the |
@xuri Thank you for your response! For instance, when I add an image using AddPicture, in my environment, the width gets scaled down to 18% and the height to 17%. In this case, it seems adjusting the height to a slightly larger scale value would make it fit nicely. However, since the aspect ratio of cells and images can vary each time, attempting to adjust based on height alone might result in exceeding the cell's height. The AddPicture function (specifically the drawResize function) first scales down the width, and if the image is still larger than the cell width, it scales down further. if float64(cellWidth) < width {
asp := float64(cellWidth) / width
width, height = float64(cellWidth), height*asp
}
if float64(cellHeight) < height {
asp := float64(cellHeight) / height
height, width = float64(cellHeight), width*asp
} Therefore, if we could know which side ends up being 100% when AutoFit is applied, I thought it would be possible to adjust the scale for either width or height accordingly. I considered doing the above calculation myself, but since there isn't a public function to obtain the width and height of a cell, I decided to ask this question. |
This related issues #260, #279 and #569. We can calculate column width by referencing the following docs (ECMA-376, ISO/IEC 29500 §18.3.1.13):
The function
The point size is 1/72 of an inch. |
@xuri Thank you for your reply! This might be slightly off-topic, but I tried to calculate cell sizes and extract margins by myself. However, I discovered that the calculation results differ between the public function GetRowHeight and the getRowHeight used internally by drawingResize.
Being able to perform the same size calculations as those done during the AutoFit in AddPicture would allow for more flexible adjustment of Scale values. Thus, I desired a function to obtain the pixel size of this cell. |
I have a question regarding the AddPicture method.
I understand that in Excel, cell sizes can change depending on the screen size and other environmental factors. Therefore, I thought about adjusting the Scale value for each environment where the file is opened. However, when using the autoFit option with AddPicture, I realized I couldn't proceed without knowing in which direction the Scale is being adjusted.
When passing {autoFit: true} in GraphicOptions, and the image is scaled down to fit the cell width, for example, with a square image in a vertically longer cell, I assume the width fills the cell and the height in pixels is adjusted accordingly.
Is there a way to know whether the adjustment is being made to the width or the height?
Additionally, if there's no way to know this, should I propose a function that returns information about the scaled-down image (for example: AddPictureAndGetInfo) via a Pull Request?
The text was updated successfully, but these errors were encountered: