Scribus Forums

Scribus => Scripts and Plugins => Topic started by: Gibbz on October 10, 2018, 02:26:33 AM

Title: PNG Export - no background option?
Post by: Gibbz on October 10, 2018, 02:26:33 AM
I have a simple script to export my document as a png. I need access to the "no background" option. But cant find the api information for this.
How can I access this setting?

My script is currently bellow:

import scribus
img = scribus.ImageExport()
document_name = scribus.getDocName()
img.name = document_name.replace(".sla",".png")
img.type = 'PNG'
img.scale = 100
img.quality = 20 # 1-100, 100 = high
img.dpi = 96
# need access to the "no-background" option here for transparency!
img.save()

Title: Re: PNG Export - no background option?
Post by: a.l.e on October 10, 2018, 09:11:20 AM
imo, just export to pdf and convert the pdf to png and taking care of transparencies.

imagemagick or pdf2image (python module) might be of help here...

in the worst case, it seems to be possible to do so with inkscape (which can be called from a python script):

https://stackoverflow.com/questions/46203639/converting-a-pdf-to-a-png-with-alpha-layer-transparency-capable-taking-way-too

imo, exporting to PNG from Scribus is only for preview purposes and having only a basic support is fine for me... as long as there are other ways to achieve the goal...

please keep us updated, if one of the hint above (or any other solution) did work for you...
Title: Re: PNG Export - no background option?
Post by: Gibbz on October 11, 2018, 06:18:13 AM
I figured as much. I only need basic output of png's. But that is on the list of basics :)

Guess I can look at making code changes for this while im at it... Thanks for your help in the other thread btw!
Title: Re: PNG Export - no background option?
Post by: a.l.e on October 11, 2018, 08:04:55 AM
yes, a patch for the scripter is probably welcome and is probably easy to add. the feature exists in scribus.

but i still think that it would have been better to keep scribus a bit simpler and document how to use python to transform a pdf into a png with a transparent background.
imo, scribus has the disposition to do too many things not that well... and i would sometimes prefer it would do slightly less but really well... most of all when there are already workflows for achieving the same result...
Title: Re: PNG Export - no background option?
Post by: Gibbz on October 11, 2018, 11:15:55 AM
ive done a patch and sample script:

https://bugs.scribus.net/view.php?id=15455
Title: Re: PNG Export - no background option?
Post by: a.l.e on October 11, 2018, 02:41:13 PM
this patch is also with spaces...
Title: Re: PNG Export - no background option?
Post by: a.l.e on October 11, 2018, 02:44:25 PM
i've uploaded a tabbed patch...