Is there a way to auto-resize the width of a row to the image height?

auto resize row width based on pasted image height from clipboard

I would assume the questioner actually wants to set width and height of any concerned cell to the values of width and height of an image he wants to show there without interfering with the contents of other cells.
I don’t know a standard tool for the purpose,and I also couldn’t learn better from the post by @Hrbrgr. Probably I missed something important.

Thinking it my way again:
The task is twofold:
-1- It must be ensured that for every concerned shape the cell it is to place in is known… Either by…
-1a The user who applies the process to describe assures every shape to be anchored to the respective cell.
-1b A piece of software finds the appropriate cell for every shape, and anchors the shape to it.

-2- Each cell to which one of the shapes is anchored must be resized to fit the shape.
-2a To do this reasonably, for every shape its own top-left corner must coincide with the one of the cell-area.
-2b Any fitting must not reduce the height or the width respectively of a row or column that was increased due to the needs of a different shape.
-2c Requirement 2b can roughly be ensured by setting very small values to size and height of all the rows/columns containing shapes, and then never decreasing such a value during the ongoing process.
-2d A solution by code for 2b I did not yet offer. I wanted to avoid a probably obscuring effect - and I wasn’t in the mood.

Above text slightly edited. Minor formal corrections. 2021-03-25 about 23:10 UTC.

You may select all the shapes of interest, and then run the short caller Sub from the code below.

Sub doBothStepsInOneGo(Optional pShapes)
If IsMissing(pShapes) Then pShapes = ThisComponent.CurrentSelection
End Sub

Sub findAndSetProperAnchorsForShapes(Optional pShapes)
On Local Error Goto fail
If IsMissing(pShapes) Then pShapes = ThisComponent.CurrentSelection
uShs = pShapes.Count - 1
For  j = 0 To uShs
  j_sh = pShapes(j)
  j_sheet = j_sh.Anchor.Spreadsheet
  j_c = 0
  While j_sheet.Columns(j_c + 1).Position.X<j_sh.Position.X
  j_c = j_c + 1
  j_r = 0
  While j_sheet.Rows(j_r + 1).Position.Y<j_sh.Position.Y
    j_r = j_r + 1
  j_cell = j_sheet.getCellByPosition(j_c, j_r)
  j_sh.Anchor = j_cell
'sh.HoriOrientPosition = 0 REM Moved to the other Sub
'sh.VertOrientPosition = 0
Next  j
End Sub

Sub resizeAnchorCellsOfShapesToFitShapesAndMoveShapesToTopLeftPositionInCells(Optional pShapes)
On Local Error Goto fail
If IsMissing(pShapes) Then pShapes = ThisComponent.CurrentSelection
uShs = pShapes.Count - 1
For j = 0 To uShs
  j_sh = pShapes(j)
  j_sh.HoriOrientPosition = 0
  j_sh.VertOrientPosition = 0
  j_sz = j_sh.Size
  j_cell = j_sh.Anchor
  If j_cell.Columns(0).Width < j_sz.Width Then j_cell.Columns(0).Width = j_sz.Width
  If j_cell.Rows(0).Height < j_sz.Height Then j_cell.Rows(0).Height = j_sz.Height
Next j  
End Sub

See LibreOffice Calc 7.0 Guide, page 214, excerpt:

Anchoring images
Anchor images so they stay in their position in relation to other items.

• To Page - anchor an image to the page to position it in a specific place. The image does not move when cells are added or deleted; it will always stay in the same position on the page where it is placed.

• To Cell - anchor an image to a cell to ensure that the image always stays with the content it is originally anchored to. If an image is anchored to cell BIO, and a new row is inserted above row 10, the image will then be anchored to cell.

• To Cell (resize with cell) - similar to To Cell but with the additional property that the image resizes as you resize the cell to which it is anchored.

To anchor a selected image or change the type of anchor used:

• Go to Format > Anchor on the Menu bar, or right-click on the image and select Anchor in the context menu, or click on the Anchor icon on the Image toolbar.

• Select To Page, To Cell, or To Cell (resize with cell) in the menu.

See also: