Skip to content

Instantly share code, notes, and snippets.

@Eumaeus
Created December 21, 2017 15:27
Show Gist options
  • Save Eumaeus/1d1ec41c11619b81a20f3d4f0907cbdf to your computer and use it in GitHub Desktop.
Save Eumaeus/1d1ec41c11619b81a20f3d4f0907cbdf to your computer and use it in GitHub Desktop.
Given a directory of images, generate pyramidal TIFF images
#!/bin/bash
#
# tilePngs.sh: convert images to pyramidal tif format using vips
#
# usage: sh tilePngs.sh <FILENAMES>
# example: sh tileImgs.sh *.png
#
# configuration:
#
# PYRAMID_DIR is the name of the output directory for pyramidal tifs.
# (Its path is relative to the working directory form which you run this script.)
PYRAMID_DIR=../tiff
#
# SRC_EXTENSION is the dot-extension on the SOURCE files: if you're
# converting .tif files, change this value to "tif" for example
SRC_EXTENSION=jpg
# Script doing the work:
VIPS=`which vips`
MV=`which mv`
for f in $*
do
echo "------------------"
baseName=$(echo $f | sed -e "s/.$SRC_EXTENSION//")
newF=${PYRAMID_DIR}/${baseName}.tif
echo "converting " $f " to " $newF " ..."
specified=${newF}":deflate,tile:256x256,pyramid"
echo $VIPS " im_vips2tiff " $f $specified
echo
$VIPS im_vips2tiff $f $specified
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment