Switch to full style
Post all Gimp scripts and script writing questions here
Post a reply

Exporting as PSD from Python?

Wed Feb 03, 2021 6:07 pm

I am importing a PSD file and exporting a composite - that works fine. I can also save it as an XCF which is helpful for debugging. Is it also possible to export back to PSD from a GIMP script? I know the command exists in the program.
I have tried both of these, where export_file_psd is the full path name ending in '.psd'. I think pdb.gimp_file_save would be correct but I am not sure what to pass in for the drawable, since I want to export everything, not just a single layer. pdb.gimp_xcf_save saves it in XCF format even if the file is named with a different extension.

Code:
pdb.gimp_xcf_save(RUN_NONINTERACTIVE, image, None, export_file_psd, export_file_psd)
pdb.gimp_file_save(image, image, export_file_psd, '?')

Re: Exporting as PSD from Python?

Thu Feb 04, 2021 5:53 am

You have to create a new drawable with whatever you want to export. Two possibilities:

1) gimp_layer_new_from_visible and export the result
2) duplicate the image, flatten it, and export its single layer.

Re: Exporting as PSD from Python?

Thu Feb 04, 2021 12:51 pm

ofnuts wrote:You have to create a new drawable with whatever you want to export. Two possibilities:

1) gimp_layer_new_from_visible and export the result
2) duplicate the image, flatten it, and export its single layer.


That is basically what I am doing when I export a composite as a PNG or JPG. That works fine.

But I don't think either of those does what I want to do in the case of exporting a PSD. I am pretty sure they will both only output a single layer, ever. In GIMP, if you open a PSD and then Export as PSD, it exports a PSD file with all the layers intact (it might rename layers that had duplicate names), not a composite. So it seems like GIMP's API does not make this feature available?
Post a reply