Scribus fill image to frame

Although, there are scripts on that do this, they were not working for me with Scribus 1.4.2, no matter what I tried. This has led me to do two things: rewrite the script, and use it on Scribus 1.5 SVN, where it works. The interface on the newer version is smoother and faster, and thus far, I haven’t hit any bugs.

Here is the script, make sure you have nothing but image frames selected:

from scribus import *
import os

if haveDoc():
    objList = []

    for i in range(selectionCount()):

    for obj in objList:
        #setScaleImageToFrame(confined to frame = bool, proportional = bool, name)
        setScaleImageToFrame(True, False, obj)
        scaleX, scaleY = getImageScale(obj)
        setScaleImageToFrame(False, True, obj)
        if scaleX > scaleY:
            scale = scaleX
            setImageScale(scale, scale, obj)
        elif scaleY > scaleX:
            scale = scaleY
            setImageScale(scale, scale, obj)



Update: I tried to open my 40 – some graphics intensive pages of my portfolio layout in 1.5 svn, and it is so sluggish, that it was unusable yet. For the 3 pages of images I was doing the testing on, it seemed fine, but it doesn’t seem that it’s optimised enough for larger documents. Or perhaps, if i were to start initially in 1.5 as opposed to 1.4.2, it may have been different.

Scripting and Automation of repetative image tasks

For a task that required the conversion of a PDF for print to image files sequence for web display, I had to figure how to export them as quickly as possible, re-combine two facing files into a single “spread”, and add a graphic element that makes them appear more like books. It is a bit of pseudo code, since I am not very familiar with Terminal, besides entering single commands, and installing add-ons in python always seems a bit daunting.

Here is the process for Ubuntu 12.04:

  • Starting with a book.pdf, convert all PDF pages to images, using ghostscript. First, open Terminal, and type “cd”, drag and drop the directory where your PDF is located into terminal, and press enter. Then, type the following command:
    gs -dNOPAUSE -dBATCH -sDEVICE=pngalpha -r300  -sOutputFile='page-%00d.png' 'book.pdf'

    Now you should have a png for each page

  • To combine them into spreads, with Imagemagick installed:
    -montage -geometry +0+0 page-2.png page-3.png spread2-3.png

    However, if you have 160 pages, handwriting that would take a bit of time, so I made a python script that makes a text file with the above command for all pages

  • In gimp, I made a gradient line in the middle to make the images appear more like book pages. I started with one of the spread, created a new layer, in which I put the gradient exactly in the middle, and then erased everything except the gradient line, keeping the dimensions exactly the same.
  • To overlay the gradient line with each of the spreads without opening Gimp or Photoshop
    composite line.png spread2-3.png
  • I am not sure yet how to develop loops with terminal, so I made the following python script that creates a text files with commands that I then copy and paste into Terminal:
    # outputs a file to use for terminal, specifically for PDFs
    #create or open a text file
    f = open("file.txt", "w")
    outNames = []
    # output spreads
    # range of pages, start with 2, since spreads usually are even-odd page
    for i in range(2,10):
        if i%2==0:
            a = i
            b = i
            c = ("s%s-%s.png" % (a,b))
            text = ("montage -geometry +0+0 page-%s.png page-%s.png %s; " % (a,b,c))
    #overlay with gradient line
    for i in outNames:
        text2 = ("composite line.png %s s%s;" % (i,i))

    I pasted a quarter at a time, so as not to crash Terminal.

To do the same simple task without a little bit of code, would either mean Batch processing in Photoshop, or manually opening in Gimp or Photoshop, which doesn’t guarantee that on each page, they gradient line would be in the exactly the same place. However, I also know that this isn’t the most efficient way yet. If anyone has any suggestions, please share them.

Clean Quad Mesh Output from Rhino

Rhino is a great program but it typically suffers from creating poor meshes that cannot be easily edited later in polygon mesh modeling software, such as Blender, Maya, etc. With the help the Paneling Tools plugin (link), it becomes very easy to create quad meshes that can later be subdivided, easily.


It is possible to create a clean quad mesh with the mesh settings from rhino (mesh command), however it is difficult to get an evenly distributed quad mesh.With paneling tools in grasshopper, it is much easier.


This demonstrates how the mesh was done. First, we create a loft, and then apply a grid on the loft. Then, we create cells, which produce mesh faces. We flatten the cells into one mesh with the mesh join component, and then we weld vertices.


mesh01-1024x576The top is the mesh from Rhino in Blender, which is then subdivided, with 2 new loop cuts introduced, which were then scaled slightly down.

Theatre seating layout with Grasshopper

Here is a script that calculates theatre seating layout. It allows for quick readjustments based on the perimeter, seat spacing, and rows. It is in 2d only, and it is very useful for testing different seating/perimeter configurations.


Link to Rhino file.