Page 1 of 1

How to find an image’s dimension and other manipulation info

Posted: Sat Aug 10, 2019 11:48 am
by _savage
Hi,

I’ve been digging around the documentation and inspecting examples, but I can’t quite gather the information I look for. This is about images and how they’re represented from UNO’s perspective; let’s look at TextGraphicObject for now:

Dimensions.
I thought that ActualSize contains the original dimension of an image, as documented, but that doesn’t seem the case. The original image (720×540px, 72px/in) dropped into Writer has the following ActualSize and Size properties:

Code: Select all

(com.sun.star.awt.Size){ Width = (long)0x40f1, Height = (long)0x30b5 }  // 16625×12469
(com.sun.star.awt.Size){ Width = (long)0x319c, Height = (long)0x2535 }  // 12700×9525
Here, Size is the same as the image’s Width and Height properties. That same image resized down then has different ActualSize and Size properties:

Code: Select all

(com.sun.star.awt.Size){ Width = (long)0xb46, Height = (long)0x87b }  // 2886×2171
(com.sun.star.awt.Size){ Width = (long)0x5a6, Height = (long)0x43d }  // 1446×1085
Here too, Size is the same as the image’s Width and Height properties. I could infer the dimensions of the image from the Graphic’s bitmap dimension, I guess.

Relative Width.
However, what I’m more interested in is the size/width of the image relative to the page’s size/width. But where do I find that page size information?

Alignment.
I’m stomped, I haven’t found where the alignment of an image is stored. There is a getPosition for Shapes (but not for TextGraphicObjects) from which I may approximate an alignment relative to the page dimensions. But considering that Word has an explicit alignment (left, center, right relative to page or text) I can’t find an equivalent here.

Mirroring.
I was surprised to see that the horizontally mirrored properties exist for odd and even pages, whereas the vertically mirrored property does not. Is that correct? And why would that be so?

Rotation.
A rotated image seems to be embedded in a ShapeCollection whose only child is the image. That’s what MRI tells me. However, iterating over the document’s DrawPages yields the image, not its collection. Anyway, it seems that rotation is expressed by two properties, GraphicRotation (no docs) which is either 0 or not defined, and RotateAngle which seems only documented in a deprecated RotationDescriptor. The value of RotateAngle (if defined) seems to be a counter-clockwise angle multiplied by 100?

Naming.
It looks like Shapes in particular have a Name and a LinkDisplayName properties, both indicating the “kind” of the shape, e.g. “Rounded Rectangular Callout n”. Are these fixed to identify the visual shape, or are these names that can be changed; if so, where can I find the actual shape definition for a Shape object?

Other Properties.
In general I noticed that the list of actual properties in MRI far exceeds the ones documented for the TextGraphicObject.

Re: How to find an image’s dimension and other manipulation

Posted: Sat Aug 10, 2019 12:16 pm
by Villeroy
_savage wrote:In general I noticed that the list of actual properties in MRI far exceeds the ones documented for the TextGraphicObject.
Service TextGraphicObject includes service BaseFrame with all of its properties and interfaces. BaseFrame includes more services and their properties and interfaces.
Then there are so called pseudo properties which are methods actually. A pair of methods value=obj.getSomething() and obj.setSomething(value) is shown as one pseudo property "Something". If property Something is read-only there is no method setSomething. In rare cases there is only a setSomething method which makes the property write-only.

No, I can't answer the the main question.

Re: How to find an image’s dimension and other manipulation

Posted: Sat Aug 10, 2019 1:25 pm
by Villeroy
Danny Brewer's excellent macro collection related to drawing objects is 16 years old: https://sourceforge.net/projects/ooomac ... r%20Tools/
I can offer a 2012 revision in odg format where I fixed some issues with variable declarations and the use of sub/functions. As far as I know, the routines do work with recent LibreOffice and OpenOffice but I did not test all the possible parameters.

P.S.: The calendar maker has another issue related to type declaration.

Re: How to find an image’s dimension and other manipulation

Posted: Sat Aug 10, 2019 1:58 pm
by JeJe
I put a 69 pixel wide image into a writer document
The width given by right click picture/Properties/width and clicking on original size = 1.46 cm

thiscomponent.drawpage.getbyindex(0).width = 1461- the same (in 10th of a mm)

thiscomponent.currentcontroller.frame.componentwindow.info.pixelPerMeterx = 4724 (on my computer)
69/4724= 0.014606... (the same)