[scribus] a new script for exporting pages using ImageExport() - feedback about FQN in context of the API

ZASKE Martin zm at revue-gugu.org
Tue Oct 18 09:33:17 UTC 2016


This is not Stack Overflow but user Juraj Fedel is getting my "green
tick" and much gratefulness.

He did understand my question and my hint that I am a newbie at
scripting and he gave me the best answer:

Here is my problem with hindsight:

Scribus help re Scripter API gives this example:

i = ImageExport()

but it did not work.



the Scribus Help is giving this:

quote==
Should I use 'from scribus import *' or 'import scribus'?
In general, 'import scribus' is preferred. 'from ... import' can get
confusing in import loops, when reloading modules, when importing
packages, and in some other circumstances. More info
http://effbot.org/zone/import-confusion.htm.
While 'import scribus' results in slightly more verbose code, it's
generally worth it in improved code readability and explictness.
quote==


In a book I found this helpful explanation (in case there are other
newbies here)

* Use “from scribus import *” to run code module functions without
module names.

* Use “import scribus” if you need to qualify your function names with a
module name using an FQN (which is the recommended approach in the
Python community).


If I apply this to the Scribus Help, and considering that "import
scribus" is heavily recommended here, then all the examples in the API
help need "scribus." added to every call of a module.

Example: where the API help gives only

ImageExport.allTypes

I need to write

scribus.ImageExport.allTypes



Sorry if this is too obvious to the veterans. We have to start somewhere.


Note to the users who wrote about exporting PDFs and then using another
program for exporting bitmaps: Thank you too. My aim was to reduce work
and to avoid mistakes by automating a boring task, which is the wrap-up
when all the creative work is done.
	Our team (for certain reasons) make many typos and other little errors
in file names.

So I am delighted to find that ImageExport() does still exist and can
export an entire batch of different bitmaps as needed and name them
correctly and place them exactly in the right folder. Because the name
is taken directly from the open Scribus document and the location for
the export is coded into my script.


In my line of work, I have needs which seem exotic to other users. So I
often get "you should not want to do this, you should to this
rather...". But if you are working in a very special situation, like
developing a new language for writing and publishing in a developing
region (we even are stretching Unicode because our region was forgotten,
when Unicode was first drafted) you cannot only use the normal workflow
like

Scribus -> PDF -> commercial print shop

We are using for one example:

Scribus -> jpeg -> 250+ subscribers on WhatsApp broadcasts

(did you know that sadly WhatsApp broadcasts are still limited to 256
subscribers? somebody even got a petition running to raise that limit)


Another example:

Scribus -> png -> Scribus -> PDF -> commercial printing on plastic sheets

A team of freelancers is producing a page each. Assembling all those
scribus files from different computers and versions was always a
nightmare. Since they all now export to standardised high-quality
loss-less PNG, we can quickly and painlessly assemble an
all-year-collection of our proverbs on one sheet A0. Not the pure way of
doing things, but works best.

I might have mentioned once or twice that Scribus is awesome for our
work. With the scripter, the awesomeness goes through the roof. Thank
you team and thank you list.

fwiw,

Martin

On 10/5/2016 6:11 PM, ZASKE Martin wrote:
> Hi again,
> 
> in July and December 2015 this list has helped us getting our workflow
> ready for our weekly distribution of decorated proverbs via WhatsApp and
> a web page.
> 
> Ever since 2015 we are manually using
> 
> File > Export > Save as Image ... >
> 
> and then we click on several options and set file type etc.
> 
> Since all our proverbs include at least one SVG vector illustration,
> typically from Openclipart.org (and since some of those SVG have
> technical issues), we have found those bitmap-exports a great help. We
> know that "normally" Scribus output should be PDF for "real
> publications" (not the point here).
> 
> As our proverbs are becoming a success, we are also pasting them up on
> paper in the villages and are also making printed tarps (rather big
> PVC-sheets for hanging outdoors) with collections of many proverbs.
> 
> So we are now generating four different exports each week in different
> file types and different resolutions and qualities, ranging from
> lightweight jpeg-thumbnails in 150x150 px to printer-ready PNG in much
> higher resolution. That is a lot of clicking and mistakes are happening
> with options or with file-names.
> 
> Now I am trying to create a Python script to help our team with all the
> exporting (so that the work is less tedious but also for having less
> human error in the process).
> 
> I have a script with "import scribus"
> 
> and I get an error message like
> 
> NameError: global name 'ImageExport' is not defined
> 
> 
> I found
> 
> class ImageExport(object)
> 
> in the Scribus help under Scripter API.
> 
> Obviously I am missing something but I looked at the wiki and tried
> searching this mail archive. I came up with this detail from Christoph:
> 
> On 7/30/2015 8:27 AM, "Christoph Schäfer" wrote:
>> There's not much to be maintained in Scribus itself here (other than correctly setting up CMake for every platform), since export to these formats is handled by Qt, not Scribus.
> 
> 
> What would it mean for a script just sending the entire page of a
> one-page-Scribus-document to the ImageExport() please?
> 
> Do I need something like "import Qt" or does it get much more
> complicated? Are there any examples at all, where I could spy on
> ImageExport() or on any other stuff that involves Qt?
> 
> Sorry if this is an annoying newbie questions, I am indeed still a
> newbie with the scripting, but I believe this is doable with the right
> syntax.
> 
> Thank you,
> 
> Martin
> 
> 


-- 
ZASKE Martin
responsable GʊGʊ
BP 50 - Bassila - Bénin
tel GʊGʊ 66.66.11.11
tel pers 97.44.62.95



More information about the scribus mailing list