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

The Application Programming Interface and the OASIS Open Document Format

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

Postby _savage » Sat Aug 10, 2019 11:48 am

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   Expand viewCollapse view
(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   Expand viewCollapse view
(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.
Last edited by _savage on Sun Aug 11, 2019 1:49 am, edited 3 times in total.
Mac 10.14 using LO 6.2.5.2, Gentoo Linux using LO 6.2.4.2.0 headless.
_savage
 
Posts: 168
Joined: Sun Apr 21, 2013 12:55 am

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

Postby Villeroy » Sat Aug 10, 2019 12:16 pm

_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.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27366
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

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

Postby Villeroy » Sat Aug 10, 2019 1:25 pm

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.
Attachments
Danny's Draw PowerTools.odg
Revision in Open Document Graphics format
(86.22 KiB) Downloaded 16 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27366
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

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

Postby JeJe » Sat Aug 10, 2019 1:58 pm

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)
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 626
Joined: Wed Mar 09, 2016 2:40 pm


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 2 guests