[scribus] Scripting a Contact Sheet
Gregory Pittman
gpittman at iglou.com
Tue Sep 23 18:37:43 CEST 2008
Henry Hartley wrote:
> 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.
>
Something else which can be done, and I have implemented it in new
versions of Infobox.pyl (found in svn for 1.3.3.x and 1.3.5), is to use
the Python Imaging Library, PIL, which will give you access to a large
number of image analysis tools to help scale frames, and get the actual
dimensions of the image.
Greg
More information about the scribus
mailing list