Skip to content

Commit

Permalink
More graphics manipulation automation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Aug 3, 2010
1 parent 04f789b commit 20a6517
Show file tree
Hide file tree
Showing 19 changed files with 252 additions and 96 deletions.
15 changes: 8 additions & 7 deletions .gitignore
@@ -1,10 +1,11 @@
*.pyc
coast/
geography-detail/
geography/
labels/
references/
snapshots/
icons/
archive
coast
geography-detail
geography
labels
references
snapshots
icons
regions.png
index.html
129 changes: 77 additions & 52 deletions Makefile
@@ -1,4 +1,9 @@

# deployment cpio archive
build/deploy.cpio: build/data.json build/labels build/regions .PHONEY
(cd www; find . | cpio -o) > build/deploy.cpio
(cd build; find data.json labels regions | cpio -o) >> build/deploy.cpio

# download archived images to set up
archive:
mkdir archive
Expand All @@ -17,10 +22,6 @@ build/components.zip: .PHONEY
build/sources.zip: .PHONEY
(cd archive; find sources | xargs zip build/sources.zip)

build/deploy.cpio: build/data.json build/labels build/regions .PHONEY
(cd www; find . | cpio -o) > build/deploy.cpio
(cd build; find data.json labels regions | cpio -o) >> build/deploy.cpio

# prepare a cross reference of regional data and label data
# for local debugging
index.html: regions.svg labels.csv
Expand All @@ -29,62 +30,86 @@ index.html: regions.svg labels.csv
build/labels: labels.py locations.csv labels/*-normalized.png
python labels.py

build/ennorath-geography-16000-export.png: geography.svg
echo this is presently a manual step in Inkscape
echo export the full page of ennorath.svg with no visible reference layers
echo at 16000x16000px
exit -1

build/ennorath-labels-16000-export: labels.svg
echo this is presently a manual step in Inkscape
echo export the full page of ennorath.svg with no visible reference layers
exit -1

build/ennorath-geography-16000-translucent.png: build/ennorath-geography-16000-export.png
echo this is presently a manual step in The GIMP
echo use the Color to Alpha tool to remove the white background color
exit -1

build/ennorath-geography-16000.png: build/ennorath-geography-16000-translucent.png
echo this is presently a manual step in The GIMP
echo use the HSL tool to drop the lightness by -100
exit -1
# this could be automated with PIL now

build/ennorath-labels-16000.png: build/ennorath-labels-16000-export.png
echo this is presently a manual step in The GIMP
echo use the HSL tool to drop the lightness by -100
exit -1
# this could be automated with PIL now
build/ennorath-geography-translucent-32768: .PHONEY
mkdir -p build/ennorath-geography-translucent-32768
bash tiles_c2a.bash build/ennorath-geography-export-32768/t build/ennorath-geography-translucent-32768/t

build/ennorath-geography-export-32768: \
build/ennorath-geography-export-16384.png \
build/ennorath-geography-export-16384-0.png \
build/ennorath-geography-export-16384-1.png \
build/ennorath-geography-export-16384-2.png \
build/ennorath-geography-export-16384-3.png
mkdir -p build/ennorath-geography-export-32768
inkscape -e build/ennorath-geography-export-32768/t.png -w 256 -h 256 geography.svg
python tiles.py build/ennorath-geography-export-16384-0.png build/ennorath-geography-export-32768/t0
python tiles.py build/ennorath-geography-export-16384-1.png build/ennorath-geography-export-32768/t1
python tiles.py build/ennorath-geography-export-16384-2.png build/ennorath-geography-export-32768/t2
python tiles.py build/ennorath-geography-export-16384-3.png build/ennorath-geography-export-32768/t3

build/ennorath-geography-export-%.png: geography.svg
inkscape -e $@ -w $* -h $* geography.svg
build/ennorath-geography-export-16384-0.png: geography.svg
inkscape -e $@ -a 0000:3600:3600:7200 -w 16384 -h 16384 geography.svg
build/ennorath-geography-export-16384-1.png: geography.svg
inkscape -e $@ -a 3600:3600:7200:7200 -w 16384 -h 16384 geography.svg
build/ennorath-geography-export-16384-2.png: geography.svg
inkscape -e $@ -a 0000:0000:3600:3600 -w 16384 -h 16384 geography.svg
build/ennorath-geography-export-16384-3.png: geography.svg
inkscape -e $@ -a 3600:0000:7200:3600 -w 16384 -h 16384 geography.svg

build/ennorath-geography-translucent-%.png: build/ennorath-geography-export-%.png
@echo $@
@echo this is presently a manual step in The GIMP
@echo use the Color to Alpha tool to remove the white background color
@exit -1

build/ennorath-labels-%-export-32768: \
build/ennorath-labels-%-export-16384.png \
build/ennorath-labels-%-export-16384-0.png \
build/ennorath-labels-%-export-16384-1.png \
build/ennorath-labels-%-export-16384-2.png \
build/ennorath-labels-%-export-16384-3.png
mkdir -p build/ennorath-labels-%-export-32768
inkscape -e build/ennorath-labels-%-export-32768/t.png -w 256 -h 256 -i layer% -j labels.svg
python tiles.py build/ennorath-labels-%-export-16384-0.png build/ennorath-labels-%-export-32768/t0
python tiles.py build/ennorath-labels-%-export-16384-1.png build/ennorath-labels-%-export-32768/t1
python tiles.py build/ennorath-labels-%-export-16384-2.png build/ennorath-labels-%-export-32768/t2
python tiles.py build/ennorath-labels-%-export-16384-3.png build/ennorath-labels-%-export-32768/t3

build/ennorath-labels-%-16000-export.png: labels.svg
@echo $@
@echo this is presently a manual step in Inkscape
@echo export the full page of ennorath.svg with only layer %
@exit -1

build/ennorath-labels-%-16000.png: build/ennorath-labels-%-16000-export.png
python darken.py $< .5 $@

labels-%-export: build/ennorath-labels-%-16000-export.png
mkdir -p build/labels-export/$*
python tiles.py $< build/labels-export/$*-

labels-%-dark: .PHONEY
mkdir -p build/labels-dark
python tiles_darken.py build/labels-export/$* build/labels-dark/$* .5

labels-%-fade:
mkdir -p build/labels-fade
python tiles_fade.py build/labels-dark/$* build/labels-fade/$*

build/tiles: build/ennorath-labels-16000.png build/ennorath-geography-16000.png
python tiles.py

build/regions: regions.svg build/ennorath-labels-16000.png build/ennorath-geography-16000.png
python regions-thumbnails.py
build/regions: regions_thumbnails.py regions.svg
# build/ennorath-labels-16000.png build/ennorath-geography-16000.png
python regions_thumbnails.py

build/regions.json: regions.svg
python regions-json.py
build/data.json: regions.svg
python data.py

regions.csv: regions.svg
python regions.py

build/ennorath-labels-8000.png: build/ennorath-labels-16000.png
python samples.py
build/ennorath-labels-4000.png: build/ennorath-labels-16000.png
python samples.py
build/ennorath-labels-2000.png: build/ennorath-labels-16000.png
python samples.py
build/ennorath-labels-1000.png: build/ennorath-labels-16000.png
python samples.py
build/ennorath-geography-8000.png: build/ennorath-geography-16000.png
python samples.py
build/ennorath-geography-4000.png: build/ennorath-geography-16000.png
python samples.py
build/ennorath-geography-2000.png: build/ennorath-geography-16000.png
python samples.py
build/ennorath-geography-1000.png: build/ennorath-geography-16000.png
python samples.py

.PHONEY:

34 changes: 17 additions & 17 deletions SETUP.md
Expand Up @@ -9,21 +9,21 @@ It is dangerous to go alone. Take these!
The large graphical content is not in the git repository.
These can be downloaded from http://3rin.gs.

make archive/components
http://3rin.gs/components.zip
contains all of the manually constructed bitmap components
for the geography and label layers.

make archive/sources
http://3rin.gs/sources.zip
contains all of the original scanes from which the components
were manually constructed. these graphics are not
necessary for generating the site. they exist if any of
the components need to be reconstructed from source material,
or for new projects.

Part of the reason for this complex setup is that I also do not
want to sync the archive or build directories to Dropbox. I unlink
the archive directory when I have Dropbox running. "build" is
a symbolic link to "archive/build".
make archive/components

[http://3rin.gs/components.zip]() contains all of the manually
constructed bitmap components for the geography and label layers.

make archive/sources

[http://3rin.gs/sources.zip]() contains all of the original scanes
from which the components were manually constructed. these graphics
are not necessary for generating the site. they exist if any of the
components need to be reconstructed from source material, or for new
projects.

Part of the reason for this complex setup is that I also do not want
to sync the archive or build directories to Dropbox. I unlink the
archive directory when I have Dropbox running. "build" is a symbolic
link to "archive/build".

18 changes: 18 additions & 0 deletions c2a.bash
@@ -0,0 +1,18 @@
#!/bin/bash
while read input; read output; do
gimp -i -b "
(let*
(
(in-filename "'"'"$input"'"'")
(out-filename "'"'"$output"'"'")
(color "'"'"#ffffff"'"'")
(image (car (gimp-file-load RUN-NONINTERACTIVE in-filename in-filename)))
(drawable (car (gimp-image-get-active-layer image)))
)
(plug-in-colortoalpha RUN-NONINTERACTIVE image drawable color)
(gimp-file-save RUN-NONINTERACTIVE image drawable out-filename out-filename)
(gimp-image-delete image)
(gimp-quit 0)
)
"
done
4 changes: 2 additions & 2 deletions darken.py
Expand Up @@ -8,14 +8,14 @@ def darken(image, factor):
image[numpy.ix_(range(x),range(y),(0, 1, 2))] *= factor
return Image.fromarray(image.astype('uint8'), "RGBA")

def darken_command(source, target, factor):
def command(source, target, factor):
image = Image.open(source)
factor = float(factor)
darken(image, factor).save(target)

def main():
import sys
darken_command(sys.argv[1], sys.argv[3], sys.argv[2])
command(sys.argv[1], sys.argv[3], sys.argv[2])

if __name__ == '__main__':
main()
Expand Down
9 changes: 6 additions & 3 deletions fade.py 100755 → 100644
Expand Up @@ -8,11 +8,14 @@ def fade(image, factor):
backdrop.paste(image, (0, 0), mask)
return backdrop

def command(source, target, factor):
image = Image.open(source)
factor = float(factor)
fade(image, factor).save(target)

def main():
import sys
image = Image.open(sys.argv[1])
factor = float(sys.argv[2])
fade(image, factor).save(sys.argv[3])
command(sys.argv[1], sys.argv[2], sys.argv[3])

if __name__ == '__main__':
main()
Expand Down
24 changes: 12 additions & 12 deletions labels.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified over.py 100755 → 100644
Empty file.
File renamed without changes.
Empty file modified scale.py 100755 → 100644
Empty file.

0 comments on commit 20a6517

Please sign in to comment.