Page 1 of 1

Cropping images

PostPosted: Tue Sep 23, 2014 10:19 am
by Biermo

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)??

Re: Cropping images

PostPosted: Wed Aug 05, 2015 1:58 pm
by frozz_night
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