Skip to content

Instantly share code, notes, and snippets.

@cwvhogue
cwvhogue / Preserve_color_resize.sh
Last active December 24, 2015 02:38
ImageMagick convert resize command including -colorspace change to preserve color.
convert 00000201.jpg -colorspace RGB -resize 250000@ -colorspace sRGB -quality 80 00000201_250.jpg
@cwvhogue
cwvhogue / Manta_thumbnails.sh
Last active December 24, 2015 02:38
Command to create thumbnails with ImageMagick convert on Joyent Manta
mfind /$MANTA_USER/public/getty -n 'jpg$' | mjob create -w -m 'convert $MANTA_INPUT_FILE -thumbnail 10000@ -strip -quality 95 PNG8:/var/tmp/out.png && mpipe ${MANTA_INPUT_OBJECT%.*}.png < /var/tmp/out.png'
@cwvhogue
cwvhogue / catchup.sh
Last active December 24, 2015 02:29
Script to populate a Manta Account with demo Getty Open images
#!/bin/bash
SITE="https://us-east.manta.joyent.com/mantademo/public/images/getty-open"
DEST="/$MANTA_USER/public"
echo Copy Demo JPEG files to your Manta Account as a tar file ...
mjob create -w -r "curl -ksL ${SITE}/demojpgs.tar | mput ${DEST}/demojpgs.tar" < /dev/null
echo Using muntar to extract the JPEG files on Manta ...
echo ${DEST}/demojpgs.tar | mjob create -o -m 'muntar -f $MANTA_INPUT_FILE /$MANTA_USER/public'
@cwvhogue
cwvhogue / Local_thumbnails.sh
Last active December 24, 2015 02:29
Command to create PNG thumbnails from JPEG images in the same directory.
time find . -name '*.jpg' -exec sh -c 'convert "{}" -thumbnail 10000@ -strip -quality 95 PNG8:`basename "{}" jpg`png' ';'
@cwvhogue
cwvhogue / identify_to_csv_local.sh
Last active December 23, 2015 18:19
Command to clean up MapReduce ImageMagick identify output and convert to .csv file
cat mr_identify.txt | \
awk '{print $7 " " $1 " " $3}' | \
sed 's/.\///' | \
sort -n | \
sed -e 's/MB/ MB/' -e 's/KB/ KB/' | \
-e 's/+0+0//' -e 's/x/ /' | \
awk '{print $1 ", " $2 ", " $3 ", " $4 ", " $5}' > Getty_Filesizes.csv
@cwvhogue
cwvhogue / identify_to_csv_manta.sh
Last active December 23, 2015 18:19
Command to clean up results of MapReduce ImageMagick identify command and output as a .csv file.
cat manta_identify_sorted.txt | \
awk '{print $7 " " $1 " " $3}' | \
sort -n | \
sed -e 's/MB/ MB/' -e 's/KB/ KB/' | \
-e 's/+0+0//' -e 's/x/ /' |
awk '{print $1 ", " $2 ", " $3 ", " $4 ", " $5}' > Getty_Filesizes.csv
@cwvhogue
cwvhogue / plot_image_dist_R.R
Last active December 23, 2015 18:19
Plots Image size distribution after ImageMagic identify MapReduce is converted to .csv and loaded in.
getty_sizes<-read.csv(header=FALSE, "Getty_Filesizes.csv")
hist(getty_sizes[,1],breaks=1000, main="Getty Open Image Size at 0.25 Megapixel", xlab="KB")
rug(getty_sizes[,1])
@cwvhogue
cwvhogue / one_machine_reduce.sh
Last active December 23, 2015 18:19
One machine Unix reduce phase for ImageMagic identify analysis MapReduce
find . -name '*.id' | xargs -I {} cat {} > mr_identify.txt
@cwvhogue
cwvhogue / one_machine_map.sh
Last active December 23, 2015 18:19
One machine image analysis map phase for MapReduce ImageMagick on Unix command line
find . -name '*.jpg' -exec sh -c 'identify "{}" > `basename "{}" .jpg`.id' ';'
@cwvhogue
cwvhogue / manta_identify_image.sh
Last active December 23, 2015 18:19
Manta MapReduce - extract image filesize, dimensions, filename with ImageMagick identify command:
mfind /$MANTA_USER/public/getty -n "jpg$" | mjob create -w -m 'identify $MANTA_INPUT_FILE' -r cat