Cropping images

The Application Programming Interface and the OASIS Open Document Format

Cropping images

Postby Biermo » Tue Sep 23, 2014 10:19 am


I habe a problem using the UNO API to crop an image inside a Impress sheet.

I know the size of an image in pixels, but to crop it, I have to know the size in millimeters. When I know the PPI of the image,
I can calc the size in mm, but where do I find the information of PPI ?

When I start Libreoffice -> Impress, right click an image, Cropping then I see the PPI at the original size,
but how can I get the information when I use the API (with java)??
OpenOffice 3.1 Windows 7
Posts: 3
Joined: Thu Oct 03, 2013 7:47 pm

Re: Cropping images

Postby frozz_night » Wed Aug 05, 2015 1:58 pm

By using python script, I manage to do crop image using the following
Code: Select all   Expand viewCollapse view
import uno
from import Size
from import Point

oAlbum = XSCRIPTCONTEXT.getDocument()
oSlides = oAlbum.getDrawPages()
oDrawPage1 = oSlides.insertNewByIndex (oSlides.Count)
oGraph = oAlbum.createInstance("")
oGraph.GraphicURL = "file:////filePath/fileName"

pxPerInch = 100*25.6
GraphSize = Size()
GraphPos = Point()
GraphSize.Width = 4.24*pxPerInch
GraphSize.Height = 3.18*pxPerInch
GraphPos.X = posList[iVar][0]*pxPerInch
GraphPos.Y = posList[iVar][1]*pxPerInch
oGraph.Size = GraphSize
oGraph.Position = GraphPos

#It only works after adding the graph, else GraphicCrop object will return None
cropFig = oGraph.GraphicCrop
cropFig.Left = 0.27*pxPerInch
cropFig.Right = 0.34*pxPerInch
cropFig.Top = 0.31*pxPerInch
cropFig.Bottom = 0.18*pxPerInch
oGraph.GraphicCrop = cropFig
LibreOffice 3.5:build-413 in OpenSuse
Posts: 1
Joined: Wed Aug 05, 2015 1:48 pm

Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 1 guest