summaryrefslogtreecommitdiffstats
path: root/test/python-image.folk
blob: d263d0da4eba73956edb96326c307c44f8deea27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
When { source builtin-programs/image/image-lib.folk }
When { source builtin-programs/image/png-lib.folk }

When the png library is /pngLib/ &\
     the image uvx argtype definer is /defineImageArgtype/ {
    set im [$pngLib loadPng "vendor/fonts/CourierPrimeCode.png"]

    fn defineImageArgtype

    set uvx [Uvx --with pillow]
    defineImageArgtype $uvx

    $uvx def saveToDisk {Image im} {
        import tempfile
        fd, path = tempfile.mkstemp(suffix='.png')
        im.save(path)
        return path
    }
    When {
        $uvx saveToDisk $im
        Exit! 0
    }
    sleep 1000 ;# to force When to run on other thread
}