[scribus] Scripting a Contact Sheet

Henry Hartley henryhartley at westat.com
Tue Sep 23 18:15:08 CEST 2008


Henry Hartley wrote:
>> I decided to change the image frames to squares so that
>> images are the same size whether horizontal or vertical
>> shots. The down side is that there isn't an obvious way
>> to center (vertically and horizontally) scaled images in
>> those frames. I may go back to rectangular frames but
>> change their orientation with the orientation of the
>> image.

The trick, it turns out, is figuring out if an image has a horizontal or vertical orientation. For anyone trying to do this, here's what I did.

# Create a temporary image object
tempImage = scribus.createImage(10, 10, 10, 10)

# Populate that object with your image
scribus.loadImage(imageFile, tempImage)

# Scale the image but NOT proportionally
scribus.setScaleImageToFrame(scaletoframe=1, proportional=0, name=tempImage)

# Use getImageScale to get the relative scaling in
# the x and y directions
imgx,imgy = scribus.getImageScale(tempImage)

If imgx < imgy, you have an horizontal image, otherwise, a vertical (or square) image. I came up with one set of coordinates for horizontal images and another for vertical and select the appropriate one based on the scaling information. Then I delete tempImage.

# Can't have these cluttering up the page
scribus.deleteObject(tempImage)

So, possibly not the best way to do it but it works and it's all I could think of. Oh, and I offset the x coordinate values on odd numbered pages since I print this double sided and it's offset for a three-hole punch.

--
Henry




More information about the scribus mailing list