Skip to content

Instantly share code, notes, and snippets.

@sixstringsg
Forked from KhasMek/khas_is_a_slacker.sh
Created October 12, 2012 17:30
Show Gist options
  • Select an option

  • Save sixstringsg/3880406 to your computer and use it in GitHub Desktop.

Select an option

Save sixstringsg/3880406 to your computer and use it in GitHub Desktop.

Revisions

  1. @KhasMek KhasMek revised this gist Oct 11, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion khas_is_a_slacker.sh
    Original file line number Diff line number Diff line change
    @@ -50,7 +50,7 @@ ls *.png *.jpg | while read line; do
    filename=`echo $line | cut -f1 -d "."`
    (cat << EOF) >> output.html
    <a href="imgs/space/$line" class="thumb_link"><span class="selected"></span><img src="imgs/space/'$filename'_thumb.$extension" title="$name" alt="$name" class="thumb" /></a>
    <a href="imgs/space/$line" class="thumb_link"><span class="selected"></span><img src="imgs/space/${filename}_thumb.$extension" title="$name" alt="$name" class="thumb" /></a>
    EOF
    done
  2. @KhasMek KhasMek revised this gist Oct 10, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions khas_is_a_slacker.sh
    Original file line number Diff line number Diff line change
    @@ -50,12 +50,12 @@ ls *.png *.jpg | while read line; do
    filename=`echo $line | cut -f1 -d "."`
    (cat << EOF) >> output.html
    <a href="imgs/space/$line" class="thumb_link"><span class="selected"></span><img src=\"imgs/space/"$filename"_thumb.$extension\" title="$name" alt="$name" class="thumb" /></a>
    <a href="imgs/space/$line" class="thumb_link"><span class="selected"></span><img src="imgs/space/'$filename'_thumb.$extension" title="$name" alt="$name" class="thumb" /></a>
    EOF
    done
    mkdir .thumbs
    find . ! -name '*.html' ! -name 'make_lazy' ! -name '.thumbs' | xargs -i cp {} .thumbs
    find . ! -name '*.html' ! -name 'khas_is_a_slacker.sh' ! -name '.thumbs' | xargs -i cp {} .thumbs
    cd .thumbs
    mogrify -resize 200x200 *.*
    # add the _small suffix
  3. @KhasMek KhasMek revised this gist Oct 10, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions khas_is_a_slacker.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    #
    # Image template creator and thumbnail maker.
    #
    # USAGE: ./khas_is_a_slacker.sh $CUSTOM_TITLE_NAME
    # USAGE: ./make_lazy $CUSTOM_TITLE_NAME
    # If CUSTOM_TITLE_NAME is blank, it will use the actual filename
    # (with underscores and all).
    # Currently supported formats are .png and .jpg.
    @@ -50,7 +50,7 @@ ls *.png *.jpg | while read line; do
    filename=`echo $line | cut -f1 -d "."`
    (cat << EOF) >> output.html
    <a href="imgs/space/$line" class="thumb_link"><span class="selected"></span><img src="imgs/space/$filename_thumb.$extension" title="$name" alt="$name" class="thumb" /></a>
    <a href="imgs/space/$line" class="thumb_link"><span class="selected"></span><img src=\"imgs/space/"$filename"_thumb.$extension\" title="$name" alt="$name" class="thumb" /></a>
    EOF
    done
  4. @KhasMek KhasMek revised this gist Oct 10, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion khas_is_a_slacker.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    #
    # Image template creator and thumbnail maker.
    #
    # USAGE: ./make_lazy $CUSTOM_TITLE_NAME
    # USAGE: ./khas_is_a_slacker.sh $CUSTOM_TITLE_NAME
    # If CUSTOM_TITLE_NAME is blank, it will use the actual filename
    # (with underscores and all).
    # Currently supported formats are .png and .jpg.
  5. @KhasMek KhasMek created this gist Oct 10, 2012.
    71 changes: 71 additions & 0 deletions khas_is_a_slacker.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    #!/bin/bash
    #
    # Image template creator and thumbnail maker.
    #
    # USAGE: ./make_lazy $CUSTOM_TITLE_NAME
    # If CUSTOM_TITLE_NAME is blank, it will use the actual filename
    # (with underscores and all).
    # Currently supported formats are .png and .jpg.
    #
    # In addition to most normal linux apps, this script will
    # require the ImageMagick suit for thumbnail creation.
    # You can find it here http://www.imagemagick.org/script/index.php

    # first, check to see if we will use a custom name for the title.
    if [ ! "$1" ]; then
    echo "Custom title name not defined."
    echo "Using actual filename instead."
    fi

    # nuke blank spaces
    rename 'y/ /_/' *

    # make all folders and filenames lowercase
    # first, rename all folders (lazy kang from another one of my scripts)
    for f in `find . -depth ! -name CVS -type d`; do
    g=`dirname "$f"`/`basename "$f" | tr '[A-Z]' '[a-z]'`
    if [ "xxx$f" != "xxx$g" ]; then
    echo "Renaming folder $f"
    mv -f "$f" "$g"
    fi
    done

    # now, rename all files
    for f in `find . ! -type d`; do
    g=`dirname "$f"`/`basename "$f" | tr '[A-Z]' '[a-z]'`
    if [ "xxx$f" != "xxx$g" ]; then
    echo "Renaming file $f"
    mv -f "$f" "$g"
    fi
    done

    # make the html and paste into the output file.
    ls *.png *.jpg | while read line; do
    if [ ! "$1" ]; then
    name=`echo $line | cut -f1 -d "."`
    else
    name="$1"
    fi
    extension=`echo $line | cut -f2 -d "."`
    filename=`echo $line | cut -f1 -d "."`
    (cat << EOF) >> output.html
    <a href="imgs/space/$line" class="thumb_link"><span class="selected"></span><img src="imgs/space/$filename_thumb.$extension" title="$name" alt="$name" class="thumb" /></a>
    EOF
    done
    mkdir .thumbs
    find . ! -name '*.html' ! -name 'make_lazy' ! -name '.thumbs' | xargs -i cp {} .thumbs
    cd .thumbs
    mogrify -resize 200x200 *.*
    # add the _small suffix
    ls | while read line; do
    extension=`echo $line | cut -f2 -d "."`
    filename=`echo $line | cut -f1 -d "."`
    mv $line ../"$filename"_thumb.$extension
    done
    # cleanup
    cd ..
    rm -rf .thumbs
    echo "conversion complete..."