Under Scribus' "Windows" menu, there is a very nice option called "Align and Distribute". This lets you align items on the page, for example centering them horizontally or vertically, aligning them to the left margin, etc. However, I have not found any way to align an image in its frame.

This script will give you a dialog window, allowing you to select on of 9 alignments:

Top Left, Top Center, Top Right

Middle Left, Middle Center, Middle Right

Bottom Left, Bottom Center, Bottom Right

When you press the "Align" button, it will align all the selected images in their frames, using the alignment option you selected. It has been tested in Scribus 1.3.3.9 and 1.3.4. It requires Tkinter to be properly installed.

Of course, if you need more fine-tuned adjustments than these 9 options, you should probably use the Image Properties toolbar to manually set the X and Y offsets of the image in its frame.

Warning: You can leave the script dialog open, and continue to process more images. However, due to a multi-threading bug with Python scripts in Scribus, if you attempt to launch another script while this one is running, Scribus will probably crash and you'll lose your document. So be careful, and save often!

New Version Fixed for 1.4.3/1.5.0

Aside from fixing it so that it works, I have also changed the import syntax to the preferred: import scribus
rather than from scribus import *.

This script has been modified again. The original command, scaleImage() is deprecated and no longer works, so now use setImageScale().

Something to note is that when you click the Align button, the work is done, but you don't see the results until you click Done – this is because the document isn't redrawn until then.

How It Works

When you start the script it first calls the Tkinter function, which sets up the dialog to choose your position for the image in the frame. When you click the Align button, the AlignImage function is called.

AlignImage is rather ingenious in how it determines how far to move the origin of the image in the frame. First, it gets the image scale settings (saveScaleX and saveScaleY). We can't really know the dimensions of this image in page units since there is no Scripter command for that. It then resizes image to frame (with keep proportions off), and rechecks the image scale again (fullScaleX and fullScaleY). We know the dimensions of this resized image, since it's the dimensions of the frame. Once it gets this information, the script then returns the image back to its original scaling.

At this point we can calculate the actual dimensions the image had originally (imageW and imageH) using the relative scales and the frame width/height values. Next, the value sent from the Tkinter function is parsed to determine how to calculate the new X and Y offsets, using frameW, frameH, imageW and imageH. Because there is a loop for all selected objects, you then move on to the next selected object and go through this same process.

It's also worth mentioning that this script also works when the scaled image is larger than the frame.