-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyramid.py
More file actions
37 lines (32 loc) · 1.01 KB
/
pyramid.py
File metadata and controls
37 lines (32 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
##script pour tuiller des grosses images non geographique
##pour utiliser L.TileLayer.Zoomift.js
import os
from wand.image import Image ##API for imageMagick
#from wand.display import display
os.chdir("/home/delaye/github/htmlMap/noMap/")
with Image(filename='orig/barbe.jpg') as img:
print img.size
iSize = img.size
imgW = iSize[0]
imgH = iSize[1]
#for tsi in range(256,imgW,256):
# ts = imgW - tsi
# z = 1
tileSize = 500
nbTiles = (imgW/tileSize) * (imgH/tileSize)
print nbTiles
myfilename = "out/"
dir = os.path.dirname(myfilename)
if not os.path.exists(dir):
os.makedirs(dir)
row = 1
column = 1
for i in range(1, nbTiles,1):
with img[((column-1)*tileSize):(column*tileSize), ((row-1)*tileSize):(row*tileSize)] as chunk:
chunk.save(filename='{}tile_{}_{}.jpg'.format(myfilename,column,row))
column += 1
print column
if(column >= imgW/tileSize):
column = 1
row += 1
#z += 1