comparison StoneWebViewer/Resources/GenerateImages.py @ 1495:fb74ed5d8c22

initial commit of the Stone Web viewer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 25 Jun 2020 16:51:10 +0200
parents
children
comparison
equal deleted inserted replaced
1494:5a3ef478deb6 1495:fb74ed5d8c22
1 #!/usr/bin/env python
2
3 # Stone of Orthanc
4 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
5 # Department, University Hospital of Liege, Belgium
6 # Copyright (C) 2017-2020 Osimis S.A., Belgium
7 #
8 # This program is free software: you can redistribute it and/or
9 # modify it under the terms of the GNU Affero General Public License
10 # as published by the Free Software Foundation, either version 3 of
11 # the License, or (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Affero General Public License for more details.
17 #
18 # You should have received a copy of the GNU Affero General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21
22 import os
23 from PIL import Image
24
25 SOURCE = os.path.dirname(os.path.abspath(__file__))
26 TARGET = os.path.join(SOURCE, '..', 'WebApplication', 'img')
27
28 try:
29 os.makedirs(TARGET)
30 except: # Directory already exists
31 pass
32
33 color = (217, 217, 217, 255)
34 border = 3
35 width = 32
36 height = 32
37
38
39
40 image = Image.new('RGBA', (width, height))
41
42 for x in range(0, width):
43 for y in range(0, height):
44 image.putpixel((x, y), color)
45
46 image.save(os.path.join(TARGET, 'grid1x1.png'), 'PNG')
47
48
49
50 image = Image.new('RGBA', (width, height))
51
52 for x in range(0, width / 2 - border):
53 for y in range(0, height / 2 - border):
54 image.putpixel((x, y), color)
55 for y in range(height / 2 + border, height):
56 image.putpixel((x, y), color)
57
58 for x in range(width / 2 + border, width):
59 for y in range(0, height / 2 - border):
60 image.putpixel((x, y), color)
61 for y in range(height / 2 + border, height):
62 image.putpixel((x, y), color)
63
64 image.save(os.path.join(TARGET, 'grid2x2.png'), 'PNG')
65
66
67
68 image = Image.new('RGBA', (width, height))
69
70 for y in range(0, height):
71 for x in range(0, width / 2 - border):
72 image.putpixel((x, y), color)
73 for x in range(width / 2 + border, width):
74 image.putpixel((x, y), color)
75
76 image.save(os.path.join(TARGET, 'grid2x1.png'), 'PNG')
77
78
79
80 image = Image.new('RGBA', (width, height))
81
82 for x in range(0, width):
83 for y in range(0, height / 2 - border):
84 image.putpixel((x, y), color)
85 for y in range(height / 2 + border, height):
86 image.putpixel((x, y), color)
87
88 image.save(os.path.join(TARGET, 'grid1x2.png'), 'PNG')