Difference between revisions of "Scripter/Images"

From Scribus Wiki
Jump to: navigation, search
(Automatic import of images: Versions not requiring Tkinter)
(Automatic import of images: Versions not requiring Tkinter)
Line 26: Line 26:
 
I started out thinking that tkinter was a desirable way to go, but I find tkinter rather ugly and hard to read, so I decided on finding a way to get around it. This results in a series of value dialogs to accomplish the same thing, though certainly more easy to understand and modify. For my personal use, I felt that either 4 or 6 images on a page served my purpose. Fewer images on a page allows for more annotations and commentary. There is almost always some need for post-script editing, but these scripts get the heavy-lifting out of the way.
 
I started out thinking that tkinter was a desirable way to go, but I find tkinter rather ugly and hard to read, so I decided on finding a way to get around it. This results in a series of value dialogs to accomplish the same thing, though certainly more easy to understand and modify. For my personal use, I felt that either 4 or 6 images on a page served my purpose. Fewer images on a page allows for more annotations and commentary. There is almost always some need for post-script editing, but these scripts get the heavy-lifting out of the way.
  
One glitch I discovered by trying these out again is that there is a problem with using '''fileDialog()''' for getting a directory, in that the dialog doesn't automatically enter the name when you click it. The workaround would be to either enter the directory you're interested it (though you have to be a level above it), or click the directory, then type './' (without the quotes) in the entry space before you click Ok.
+
One glitch I discovered by trying these out again is that there is a problem with using '''fileDialog()''' for getting a directory, in that the dialog doesn't automatically enter the name when you click it. The workaround would be to either enter the directory you're interested in (though you have to be a level above it), or click the directory, then type './' (without the quotes) in the entry space before you click Ok.
 
|}
 
|}
  

Revision as of 17:15, 4 November 2016

This article is part of the Scripts series.

I decided to beef up this page a bit, since we get a number of questions about whether a script can be written for some task or other, and one quickly realizes that it takes some time to find all the scripts that deal with such a task. What people really need is a quick survey of what's out there, so that they can either modify some existing script themselves, or be able to ask for help with the modification for their particular needs.

I'll try to start with simple scripts first, then go to more complicated or perhaps esoteric ones down the page.

Import an image in the way office-programs do

This script does the simple task of taking an image file and making a standard image frame and loading it onto a page. In a modified state, it is one of the scripts included with Scribus, DirectImageImport.py.

The presumption is that you will then resize and reposition this image in most cases. One downside in the modified script is its need for PIL, the Python Imaging Library. The advantage of PIL is that you end up with a frame exactly dimensioned for the image, and importantly the frame ends in a state of scaled to frame proportionally, so resizing keeps the proportions.

Directimageimportresults.png

Image Wizard: Scale and Align an Image

With this idea that you have imported an image, but want to adjust various details about it, we come to Image Wizard. I confess I haven't tried this one to make sure it still works, but what it does is use tkinter to create a remote control-like structure for a number of manipulations as shown. While I can understand that for a Scribus novice this might seem a great tool, realistically most of these manipulations are easily done without a script. For example, right-clicking on an image frame brings up a context menu to adjust frame to image or image to frame. Flipping horizontally and vertically are one-click operations in the X,Y,Z tab.

ImageWizard3.png

You might also have a look at Align an Image in its Frame . This does the simple task of aligning an image in the frame, such as upper left corner or centering, again using tkinter, though here you can select multiple image frames at once before running the script.

Likewise, there is Scale an Image to Fill a Frame Proportionally. Just as with Image Wizard, this scaling of images is now done so easily on the main screen there is probably little need for this.

Automatic import of images: Versions not requiring Tkinter

Scribalbumexample.png In addition to this particular wiki page, you might also look at Automatic import of images from a directory using a script and Making a photobook from a directory of images using a script. All of these in their own way is operating from the point of view that you have a directory of images that you wish to incorporate into a Scribus document. It's one thing if you have half a dozen images, but what about a directory of 60 or 100? That's a lot of image frame creation!

I started out thinking that tkinter was a desirable way to go, but I find tkinter rather ugly and hard to read, so I decided on finding a way to get around it. This results in a series of value dialogs to accomplish the same thing, though certainly more easy to understand and modify. For my personal use, I felt that either 4 or 6 images on a page served my purpose. Fewer images on a page allows for more annotations and commentary. There is almost always some need for post-script editing, but these scripts get the heavy-lifting out of the way.

One glitch I discovered by trying these out again is that there is a problem with using fileDialog() for getting a directory, in that the dialog doesn't automatically enter the name when you click it. The workaround would be to either enter the directory you're interested in (though you have to be a level above it), or click the directory, then type './' (without the quotes) in the entry space before you click Ok.

Split Image Across Gutter

This is trickier than you might think, mostly related to the "lost" space in the binding of a book. Obviously, you will need to know this lost space, since it is an entry you must make in the script.

SplitImageAcrossGutter2.png

Image crop, resize and CMYK conversion. Save and reload in TIFF format

I've not used this script, though it does generally seem to be a useful thing. The one thing I would question is whether the colorspace conversion is necessary, since we mostly recommend that users let Scribus do the colorspace conversion to CMYK.