File: export-splash.py

package info (click to toggle)
gimp 3.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 210,368 kB
  • sloc: ansic: 845,152; lisp: 10,855; python: 10,330; cpp: 7,238; perl: 4,382; sh: 1,412; xml: 963; yacc: 609; lex: 348; javascript: 150; makefile: 43
file content (23 lines) | stat: -rw-r--r-- 778 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
import sys

image     = Gimp.get_images()[0]
procedure = Gimp.get_pdb().lookup_procedure("file-png-export")
config    = procedure.create_config()
image.undo_disable()
image.flatten()

if image.get_width() > 1920 or image.get_height() > 1080:
  factor = max(image.get_width() / 1920, image.get_height() / 1080)
  new_width  = image.get_width() / factor
  new_height = image.get_height() / factor
  image.scale(new_width, new_height)

drawables = image.get_selected_drawables()
config.set_property("image", image)
config.set_property("file", Gio.file_new_for_path("gimp-data/images/gimp-splash.png"))
config.set_property("time", False)
config.set_property("format", "rgb8")
retval = procedure.run(config)
if retval.index(0) != Gimp.PDBStatusType.SUCCESS:
  sys.exit(70)