Scribus Forums

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

Title: PNG Export - no background option?
Post by: Gibbz on October 10, 2018, 03: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:
Code: [Select]
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, 10: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, 07: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, 09: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, 12:15:55 pm
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, 03: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, 03:44:25 pm
i've uploaded a tabbed patch...