File: test-image.py

package info (click to toggle)
gimp 3.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 222,880 kB
  • sloc: ansic: 870,914; python: 10,965; lisp: 10,857; cpp: 7,355; perl: 4,536; sh: 1,753; xml: 972; yacc: 609; lex: 348; javascript: 150; makefile: 42
file content (19 lines) | stat: -rw-r--r-- 856 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python3

NEW_IMAGE_WIDTH=1920
NEW_IMAGE_HEIGHT=2001

image = Gimp.Image.new(NEW_IMAGE_WIDTH, NEW_IMAGE_HEIGHT, Gimp.ImageBaseType.RGB)
gimp_assert('Gimp.Image.new()', type(image) == Gimp.Image)

images = Gimp.get_images()
gimp_assert('Gimp.get_images()', len(images) == 1 and images[0] == image)

text_layer = Gimp.TextLayer.new(image, "hello world", Gimp.context_get_font(), 20, Gimp.Unit.point())
gimp_assert('Gimp.TextLayer.new() with point unit', type(text_layer) == Gimp.TextLayer)

gimp_assert('Gimp.Image.InsertLayer()', image.insert_layer(text_layer, None, 0))

text_layer = Gimp.TextLayer.new(image, "hello world", Gimp.context_get_font(), 20, Gimp.Unit.pixel())
gimp_assert('Gimp.TextLayer.new() with pixel unit', type(text_layer) == Gimp.TextLayer)
gimp_assert('Gimp.Image.InsertLayer()', image.insert_layer(text_layer, None, 0))