Skip to content

Instantly share code, notes, and snippets.

@cwvhogue
cwvhogue / Manta_Getty_Originals.sh
Created September 27, 2013 17:12
Script to populate a Joyent Manta account with Getty Open Content originals, capped at 20.
#!/bin/bash
SITE="https://us-east.manta.joyent.com/mantademo/public/images/getty-open/"
DEST="/$MANTA_USER/public/"
# For more files change "-20" below to a larger number.
# For the complete download, remove "head -20 |" below
mmkdir -p ${DEST}/originals
curl -ksL ${SITE}/filelist.txt | head -20 | mput ${DEST}/filelist.txt
echo ${DEST}/filelist.txt | mjob create -m "xargs -I {} sh -c 'curl -ksL ${SITE}/originals/{} | mput ${DEST}/originals/{}'"
@cwvhogue
cwvhogue / Getty_Originals_dnld.sh
Created September 27, 2013 17:08
Script to download the Getty Open Originals from Joyent Manta
#!/bin/bash
curl -k https://us-east.manta.joyent.com/mantademo/public/images/getty-open/filelist.txt > filelist.txt
cat filelist.txt | xargs -I {} curl -k https://us-east.manta.joyent.com/mantademo/public/images/getty-open/originals/{} -o {}
@cwvhogue
cwvhogue / Manta_resize_color_preserve.sh
Created September 27, 2013 16:56
Image resize job with color preservation on Joyent Manta.
time mfind /$MANTA_USER/public/art -n '1.jpg$' | mjob create --memory 2048 -w -m 'convert $MANTA_INPUT_FILE -colorspace RGB -resize 250000@ -colorspace sRGB -quality 80 /var/tmp/out.jpg && mpipe ${MANTA_INPUT_OBJECT%.*}_s.jpg < /var/tmp/out.jpg'
@cwvhogue
cwvhogue / Local_resize_color_preserve.sh
Last active December 24, 2015 02:39
Unix command to process resize operation with color preservation
find . -name '*.jpg' -exec sh -c 'convert "{}" -colorspace RGB -resize 250000@ -colorspace sRGB -quality 80 `basename "{}" .jpg`_250.jpg' ';'
@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