Skip to content

Commit

Permalink
scribus generation script:
Browse files Browse the repository at this point in the history
 - move config data to extra files
  • Loading branch information
backface committed Nov 21, 2012
1 parent a1bdb35 commit 9767fb0
Show file tree
Hide file tree
Showing 7 changed files with 399 additions and 150 deletions.
56 changes: 36 additions & 20 deletions tools/generate_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
verbose = True
trackfile = "track.gpx"
tracklogfile = "track.log.csv"
logstyle = "one"

def usage():
print """
Expand Down Expand Up @@ -119,26 +120,41 @@ def process_args():
th_width = int(w * ratio)

if process_logs:
if os.path.exists(file + ".log"):
logreader = csv.reader(open(file + ".log","rb"), delimiter=";")
try:
pattern1 = "none";
pattern2 = "1970-01-01T00:00:00.0Z"

if logstyle == "one":
if count == 0:
logreader = csv.reader(open(file + ".log","rb"), delimiter=" ")
for line in logreader:
# discard non-valid fixes
if not re.search(pattern1, line[2]) and not re.search(pattern2, line[1]):
if not line[0] == ";": #temp hack
logwriter.writerow(line)
infowriter.addPoint(
float(line[3]), float(line[4]),
line[1], float(line[5]), float(line[6]))
gpxwriter.addTrackpoint(float(line[3]), float(line[4]),
line[1], float(line[5]), float(line[6]),
line[2],"",line[0]
)
else:
print "discard non-valid gps log for at %s, fix: %s" % (line[1],line[2])
except:
print "x"
#print float(line[2]), float(line[3])
try:
infowriter.addPoint(float(line[2]), float(line[3]))
gpxwriter.addTrackpoint(float(line[2]), float(line[3]))
except:
print "value error"

else:
if os.path.exists(file + ".log"):
logreader = csv.reader(open(file + ".log","rb"), delimiter=";")
try:
pattern1 = "none";
pattern2 = "1970-01-01T00:00:00.0Z"
for line in logreader:
# discard non-valid fixes
if not re.search(pattern1, line[2]) and not re.search(pattern2, line[1]):
logwriter.writerow(line)
infowriter.addPoint(
float(line[3]), float(line[4]),
line[1], float(line[5]), float(line[6]))
gpxwriter.addTrackpoint(float(line[3]), float(line[4]),
line[1], float(line[5]), float(line[6]),
line[2],"",line[0]
)
else:
print "discard non-valid gps log for at %s, fix: %s" % (line[1],line[2])
except:
print "x"

if not os.path.exists(thumb_file) and process_images:
# generate thumbs
Expand All @@ -158,7 +174,7 @@ def process_args():
info = infowriter.getInfoStringHTML()
infowriter.save()
gpxwriter.save()
info += '&raquo;<a href="%s">trackfile</a>' % trackfile
info += '&raquo; <a href="%s">trackfile</a>' % trackfile
else:
info = "no gps log data available."

Expand All @@ -181,7 +197,7 @@ def process_args():
<head>
<body>
<h2>%s</h2>
<div id="info">%s</div>
<div id="info"><p>%s</p></div>
<div id="thumbs">
%s
</div>
Expand Down
94 changes: 94 additions & 0 deletions tools/scribus/a4-overview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/usr/bin/env python

from scribus import *
import os, time, datetime, math

######################################
imagepath = "/data/projects/slitscan/malisca/tile-data/2011-12-16--chunar-banares/2592x2592"
imagepath = "/data/projects/slitscan/malisca/tile-data/2011-06-17--linz-krems/2592x1296/"
page_size = PAPER_A4
#page_size = (209.9,297.0) #A4
#page_size = (216.2,303.3) #A4 + Lulu bleed
bleed = 6.3
orientation = LANDSCAPE # LANDSCAPE or PORTRAIT
tiles_per_row = 5
margin_fac = 0.25
linewidth=0.7
limit = 0
###################################

filetype = []
dicttype = {'j':'.jpg','p':'.png','t':'.tif','g':'.gif','P':'.pdf','J':'.jpeg'}
Dicttype = {'j':'.JPG','p':'.PNG','t':'.TIF','g':'.GIF','P':'.PDF','J':'.JPEG'}
imagetype = "jJptgP"
#valueDialog('Image Types','Enter the Image Types, where\n j=jpg,J=jpeg,p=png,t=tif,g=gif,P=pdf\n "jJptgP" selects all','jJptgP')
for t in imagetype[0:]:
filetype.append(dicttype[t])
filetype.append(Dicttype[t])

D=[]
d = os.listdir(imagepath)
d.sort()
for file in d:
for format in filetype:
if file.endswith(format):
D.append(file)
D.sort()

page_w = page_size[1]
page_h = page_size[0]

tile_w = page_w / float(tiles_per_row)
tile_h = tile_w * 512 / 1000
#tile_h = tile_w

num_rows = math.floor(page_h / (tile_h + tile_h * margin_fac))
margin_h = (page_h - ( num_rows * tile_h + (num_rows-1) * tile_h * margin_fac )) / 2

progressTotal(len(D))
imagecount = 400
pagecount = 0
xpos = 0
ypos = margin_h

if not limit > 0:
limit = len(D)

if len(D) > 0:
#if newDocument(page_size, (bleed,bleed,bleed,bleed), orientation, 1, UNIT_MILLIMETERS, FACINGPAGES, FIRSTPAGERIGHT, 1):
if newDocument(page_size, (bleed,bleed,bleed,bleed), orientation, 1, UNIT_POINTS, NOFACINGPAGES, 0, 1):

while imagecount < limit:
filename,ext = os.path.splitext(D[imagecount])

if imagecount < limit:
f = createImage(xpos, ypos, tile_w, tile_h)
loadImage(imagepath + "/" + D[imagecount], f)
setScaleImageToFrame(scaletoframe=1, proportional=1, name=f)
imagecount = imagecount + 1

xpos += tile_w

if xpos >= page_w - 0.1:
xpos = 0
ypos = ypos + tile_h + tile_h *margin_fac

# new page
if (imagecount < limit and ypos + tile_h >= page_h):
newPage(-1)
ypos = margin_h
xpos = 0


progressSet(imagecount)
#redrawAll()
#setRedraw(1)



setRedraw(1)
redrawAll()

else:
result = messageBox ('Not Found','No Images found with\n this search selection',BUTTON_OK)

103 changes: 103 additions & 0 deletions tools/scribus/a6-postkarten.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/usr/bin/env python

from scribus import *
import os, time, datetime, math

######################################
imagepath = "/data/projects/slitscan/malisca/tile-data/2011-12-16--chunar-banares/128"
imagepath = "/data/projects/slitscan/malisca/tile-data/2012-03-21--istanbul-straight/128"
imagepath = "/data/projects/slitscan/malisca/tile-data/2011-04-27--westautobahn-II/128x128"
imagepath = "/data/projects/slitscan/malisca/tile-data/2011-12-13--varanasi-deshaked/128"
imagepath = "/data/projects/slitscan/malisca/tile-data/2011-12-13--varanasi/128"
imagepath = "/data/projects/riverstudies/nile/tiles/2006-12-21-dv--edfu/"
imagepath = "/data/projects/slitscan/malisca/tile-data/2012-01-08--guwahati-north-deshaked/128"

#imagepath = "/data/projects/slitscan/malisca/tile-data/2011-12-13--varanasi-east/128"
#imagepath = "/data/projects/slitscan/malisca/tile-data/2011-06-17--linz-krems/128/"
page_size = PAPER_A6
#page_size = (209.9,297.0) #A4
#page_size = (216.2,303.3) #A4 + Lulu bleed
bleed = 6.3
orientation = LANDSCAPE # LANDSCAPE or PORTRAIT
tiles_per_row = 9
offset = 1
margin_fac = 0.2 # 0.25
linewidth=0.7
limit = 0
###################################

filetype = []
dicttype = {'j':'.jpg','p':'.png','t':'.tif','g':'.gif','P':'.pdf','J':'.jpeg'}
Dicttype = {'j':'.JPG','p':'.PNG','t':'.TIF','g':'.GIF','P':'.PDF','J':'.JPEG'}
imagetype = "jJptgP"
#valueDialog('Image Types','Enter the Image Types, where\n j=jpg,J=jpeg,p=png,t=tif,g=gif,P=pdf\n "jJptgP" selects all','jJptgP')
for t in imagetype[0:]:
filetype.append(dicttype[t])
filetype.append(Dicttype[t])

D=[]
d = os.listdir(imagepath)
d.sort()
for file in d:
for format in filetype:
if file.endswith(format):
D.append(file)
D.sort()

page_w = page_size[1]
page_h = page_size[0]

tile_w = page_w / float(tiles_per_row)
tile_h = tile_w
#tile_h = tile_w / 4

num_rows = math.floor(page_h / (tile_h + tile_h * margin_fac))
margin_h = (page_h - ( num_rows * tile_h + (num_rows-1) * tile_h * margin_fac )) / 2

progressTotal(len(D))
imagecount = offset
pagecount = 0
xpos = 0
ypos = margin_h

if not limit > 0:
limit = len(D)

if len(D) > 0:
#if newDocument(page_size, (bleed,bleed,bleed,bleed), orientation, 1, UNIT_MILLIMETERS, FACINGPAGES, FIRSTPAGERIGHT, 1):
if newDocument(page_size, (bleed,bleed,bleed,bleed), orientation, 1, UNIT_POINTS, NOFACINGPAGES, 0, 1):

while imagecount < limit:
filename,ext = os.path.splitext(D[imagecount])

if imagecount < limit:
f = createImage(xpos, ypos, tile_w, tile_h)
loadImage(imagepath + "/" + D[imagecount], f)
setScaleImageToFrame(scaletoframe=1, proportional=1, name=f)
imagecount = imagecount + 1

xpos += tile_w

if xpos >= page_w - 0.1:
xpos = 0
ypos = ypos + tile_h + tile_h *margin_fac

# new page
if (imagecount < limit and ypos + tile_h >= page_h):
newPage(-1)
ypos = margin_h
xpos = 0


progressSet(imagecount)
#redrawAll()
#setRedraw(1)



setRedraw(1)
redrawAll()

else:
result = messageBox ('Not Found','No Images found with\n this search selection',BUTTON_OK)

Empty file.
27 changes: 27 additions & 0 deletions tools/scribus/config/config_poster_a1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
######################################
# -*- coding: utf-8 -*

from scribus import *

class Config:

imagepath = "/data/projects/slitscan/malisca/tile-data/2011-04-27--westautobahn-II/1440x320/"
offset = 0
limit = 0

readLogs = False
logstyle = "new"

page_size = PAPER_A0
orientation = LANDSCAPE # LANDSCAPE, PORTRAIT
units = UNIT_POINTS

footer = "Copyright © Michael Aschauer, 2011"
title = "A1 Westautobahn"

margin = 14.2
margin_fac = 0.33




Loading

0 comments on commit 9767fb0

Please sign in to comment.