Imagedata format in SLA file

Previous topic - Next topic

skhullar

Hi

I know it's not recommended to parse SLA file as against creating a Py script. However our use case requires parsing. 

We are stuck at embedded Imagedata, which seems to be some kind of compressed base64 format. Need to know how to decode it and extract the image (without a script)

Thanks

Sunil

utnik

hi sunil

if you just need to extract your image from the .sla file, you can do it with a right click on the image. in the pop-up menu you uncheck 'image' → 'embed image'. then scribus will open a window to define the name and location for the extracted image.

utnik


a.l.e

hi sunil

i guess that utnik does not really answer your question.

but his reply contains a very good hint: have a look at how scribus reads or write the images and you will understand what you need to do to extract the image.

you can search through the code for the commands you see in the menues and you can then walk back to the relevant snippets.

skhullar

Hi a.l.e

I was hoping to get some ready made help. But you are asking me to look into code. That will involve lot of deep diving, I wanted to avoid.


a.l.e

#4
no, i'm not asking you to look into the code.

i'm suggesting that you can find the solution by looking into the code.
or, at least, this is how i would do it.
if you're parsing the xml, and -- among other things -- want to extract the images from the xml soup you probably know how to do that.

good luck!

p.s.: you are parsing an undocumented file format... at some time, you will need to go into the code to understand what's the meaning of the things you will be finding...

utnik

i still don't understand why the extraction of embedded images calls for parsing the .sla file...

a.l.e

hi utnik,

now that i think about it, i also can't really find a use case where this would be necessary.

if one wants to create scripts that process the .sla and modify the images, it's much easier not to use embedded images at all...

maybe they're processing scribus files created from pdfs or from idml?

who knows, maybe one day we will find out what sunil is up to...

Nermander

Maybe someone has several SLAs with dozens of embedded images and don't want to extract them manually one by one?

AdmFubar

thought i might have a solution, and tried "collect for output" option .. alas embedded images stay firmly planted in the .sla and not exported into a sub-directory as i had hoped.

From what i can gather by looking over the available commands in python, there seems to be no option to allow exporting embedded images via a script. I checked even for a command to remove the embedding, nothing available to implement that idea.

Look like the only recourse is to parse the .sla , find the point(s) where the embedded image(s) and decode,extract and save them.
Using Scribus 1.6.1, openSUSE 15.5
Advanced hobbyist

a.l.e

@Nermander : in that case i would suggest to create a pdf and extract the images from there : - )

@AdmFubar : yes, i thought that it might be missing. but rather than fighting the xml, the better solution is to create the commands for exporting the images and submit a patch (or ask the community to create the commands).
then the problem is not only solved for the one user, but for everybody (creating a command for the scripter is a bit more tedious than necessary, but to 90% copy paste work)

AdmFubar

As he needs a solution more now than later, the option to extract the image from the .sla is more immediate solution. Another option would be to export as a pdf, and use a pdf tool to extract the image(s). Not sure how promising a solution it would be, as the full image in scribus i bet is masked by the frame in the pdf. but would be work looking into, and may suit his needs.
Using Scribus 1.6.1, openSUSE 15.5
Advanced hobbyist