Skip to content

Instantly share code, notes, and snippets.

@carlynorama
carlynorama / make_map_from_tiles.sh
Last active August 29, 2015 14:11
Create a bigger image from a set of images with the files names 00y00x (can make a subset of a bigger set image)
#!/bin/bash
#creates a montage of images from a selection of
#properly named files. The top left is 0, 0. The bottom
#right is presumed to be 7, 15. A subset of the map
#can be built with the correct inputs to the script.
#REQUIRES IMAGEMAGICK
#------------------------------ INPUTS -----------------------------#
#the first parameter passed to the shell script
@carlynorama
carlynorama / prep_image_files_with_borders.sh
Last active August 29, 2015 14:11
Trim images with too much whitespace and then add a border of a set value
#!/bin/bash
#based on code found here:
#http://jcornuz.wordpress.com/2007/10/26/imagemagick-and-bash-batch-power/
#This script takes an image with a lot of extra border, trims it down
#and then re-adds a 20 pixel border evenly around the edge.
#REQUIRES IMAGEMAGICK AND GHOSTSCRIPT
#the tiles will be put in a directory called...
MYDIR="PROCESSED"
#!/bin/bash
#Leaves the stats area intact and a 2px black
#border on the other edges. Saves file to a
#sub-direcotry
if [ ! -d ./PROCESSED ]; then mkdir ./PROCESSED;
fi
# processes all pngs
if ls | grep png; then for p in *.png;
@carlynorama
carlynorama / crop_rename.sh
Last active August 29, 2015 14:12
Crops an image file to a specified size and offset, renames with same prefix as original. Requires ImageMagick.
#!/bin/bash
#Crops an image file to a specified size and offset,
#renames with same prefix as original.
#REQUIRES ImageMagick.
Y1=$1
Y2=$2
X1=$3
X2=$4
@carlynorama
carlynorama / rename_with_map_prefix.sh
Last active August 29, 2015 14:12
This script parses an image that has a legend in the top left hand corner. If an area of the corner is green then the file gets copied to a new directory with the appropriate coordinates.
#!/bin/bash
#Reduce time by running process for just the part of the
#grid actually represented
Y1=$1
Y2=$2
X1=$3
X2=$4
#used in prefix generation
@carlynorama
carlynorama / ImageMagick_resized_gifs.sh
Created January 1, 2015 22:25
Make GIFs from PNG wit ImageMagick
mogrify *.png -gravity South -crop 1200x860+0+0 +repage *.png
convert -delay 50 *.png -colors 256 -loop 0 toT5_50.gif
convert toT5_50.gif -resize 310x215 tot5_50_tumb.gif
#Also could have used percentage resize:
#convert toT5_50.gif -resize 25% -colors 256 toT5_50_tumb.gif
@carlynorama
carlynorama / PNG_to_MP4.sh
Last active August 29, 2015 14:12
Making a movie from PNG with FFMPEG
#REQUIRES FFMPEG
mogrify *.png -gravity south -crop 1240x860+0+0 +repage *.png
ffmpeg -framerate 4 -pattern_type glob -i '*.png' -c:v libx264 -pix_fmt yuv420p output.mp4
@carlynorama
carlynorama / rename_with_map_prefix_T2.sh
Last active August 29, 2015 14:15
This image scans the top left corner of an image for a green spot at particular locations. Shifted for use in the Moon Temple.
#!/bin/bash
#This image scans the top left corner of an image for a
#green spot at particular locations.
#Values shifted for use in the Moon Temple
#y values work for Manji Temple but not X
#Reduce time by running process for just the part of the
#grid actually represented
Y1=$1
@carlynorama
carlynorama / lpthw_ex12_logger.py
Last active August 29, 2015 14:19
LPTHW example 12 updated to log results to file.
#http://www.cyberciti.biz/faq/howto-get-current-date-time-in-python/
#https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior
#http://learnpythonthehardway.org/book/ex12.html
import datetime
filename= "mydata.txt"
logtime = datetime.datetime.now()
@carlynorama
carlynorama / lpthw_ex16_changinglines.py
Last active August 29, 2015 14:19
Update a file with new user input preserving first few lines as a header. Started from LPTHW Example 16
#http://learnpythonthehardway.org/book/ex16.html
#http://stackoverflow.com/questions/11584247/how-can-i-simplify-this-series-of-target-write-commands
#http://stackoverflow.com/questions/12790983/multiline-file-read-in-python
from sys import argv
script, filename = argv
title_lines = 2