Hello,
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)??
Cropping images
-
- Posts: 1
- Joined: Wed Aug 05, 2015 1:48 pm
Re: Cropping images
By using python script, I manage to do crop image using the following
Code: Select all
import uno
from com.sun.star.awt import Size
from com.sun.star.awt import Point
oAlbum = XSCRIPTCONTEXT.getDocument()
oSlides = oAlbum.getDrawPages()
oDrawPage1 = oSlides.insertNewByIndex (oSlides.Count)
oGraph = oAlbum.createInstance("com.sun.star.drawing.GraphicObjectShape")
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
oDrawPage1.add(oGraph)
#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