#!/bin/bash
#via http://cubiq.org/create-fixed-size-thumbnails-with-imagemagick
###
### CREATE PICTURE THUMBS
### v1.0
###
#
# Choosing size (versions)
# * 350px q70 = 50k
# * 450px q75 = 60k
# * 600px q80 = 80k <-------- current
#
#
# NEXT v2.0
#
# * recursive (atm only "current folder")
#
# * skip the already done
#
# * video
# * resizing / recoding
# * or atleast create core stills + audio / speex!
# * ...
#
#
# -------------------------------------------------------------------- PAD
#
# i think this project is one of those ODDLY OUT OF TIME
# it would be better 10 years ago!
# time is running against it!
# * "disk space not a problem"
# * "image loading speed not a problem"
# however
# (i think it actually still is a problem)
#
#
_size="1024"
_q="85"
_dest="0thumbs"
#
# went form 20 to 1mb (20 fold reduction)
#
#
# Works
# Problem : makes whitearound ...
# SEE
# http://askubuntu.com/questions/271776/how-to-resize-an-image-through-the-terminal
#
#mogrify -resize ${_size}x${_size} -background white -gravity center -extent ${_size}x${_size} -format jpg -quality 75 -path thumbs *.jpg
##########################
#
# overview jun 25
# * doing on ANDROID
# * 2.5 GB -> ? 100MB = 25x smaller
# * started 1803 ... 1808 ... around 5min
# * TODO : THERE IS NO PROGRESS BAR !!!!
#
#
#
# PROGRESS BAR
#
# ls | grep jpg | wc -l
#
#fail
#function PROGRESS {
# ls | wc -l
#}
# TODO !!!!!!!!! NOW jun26
#_total=$(find | egrep '(\.jpg)|(\.JPG)' | wc -l)
_lol=$(__find_count "jpg")
_total=$(__find_count "jpg|mp4")
_all="$_lol"
#watch "echo Images/Images+Videos : $_lol/$_total" #/$_total <-- ow yeah"
#
#
# DIFFERENCE
# Ok, I made thumbs before
# Don't do the same ones again??!
#
#
#
# TIME FAILS
# Compare names + EXIF data ?!
# no no, that won't work ...
#
#
##########################
echo
cowsay "Create thumbs"
echo "Max edge ${_size}px, q=${_q}, destination folder '$_dest'" | __color
__confirm
echo
mkdir "$_dest"
echo
echo "Doing *.jpg" | __color
mogrify -scale ${_size}x${_size} -format jpg -quality $_q -path "$_dest" *.jpg &
mogrify -scale ${_size}x${_size} -format jpg -quality $_q -path "$_dest" *.JPG &
mogrify -scale ${_size}x${_size} -format jpg -quality $_q -path "$_dest" *.png &
#possible improve
#1) -adjoin / -mosiac : ..... OK THIS WOULD BE BAD -- GALERIES NEED TO BE DONE AT FRONTEND LEVEL RIGHT
#2) caption / label images (for example with assigned tags)
#3) DO NOT OVERWRITE (leave existing thumbs alone)
#4) ...
#watch -n0.1 "echo Images/Images+Videos, in $_dest : $(ls -1 $_dest| wc -l) of $_lol" #/$_total <-- ow yeah"
#watch -n0.1 "echo Images/Images+Videos, in $_dest : $(ls -1 $_dest | wc -l) of $_lol" #/$_total <-- ow yeah"
#watch -n0.1 "ls 0thumbs | wc -l"
watch -c -n0.1 "__progress_bar $_dest $_all"
# WATCH -c has color YAY
#echo
#echo "Doing *.JPG" | __color
#mogrify -scale ${_size}x${_size} -format jpg -quality $_q -path "$_dest" *.JPG
echo
echo
#via http://cubiq.org/create-fixed-size-thumbnails-with-imagemagick
###
### CREATE PICTURE THUMBS
### v1.0
###
#
# Choosing size (versions)
# * 350px q70 = 50k
# * 450px q75 = 60k
# * 600px q80 = 80k <-------- current
#
#
# NEXT v2.0
#
# * recursive (atm only "current folder")
#
# * skip the already done
#
# * video
# * resizing / recoding
# * or atleast create core stills + audio / speex!
# * ...
#
#
# -------------------------------------------------------------------- PAD
#
# i think this project is one of those ODDLY OUT OF TIME
# it would be better 10 years ago!
# time is running against it!
# * "disk space not a problem"
# * "image loading speed not a problem"
# however
# (i think it actually still is a problem)
#
#
_size="1024"
_q="85"
_dest="0thumbs"
#
# went form 20 to 1mb (20 fold reduction)
#
#
# Works
# Problem : makes whitearound ...
# SEE
# http://askubuntu.com/questions/271776/how-to-resize-an-image-through-the-terminal
#
#mogrify -resize ${_size}x${_size} -background white -gravity center -extent ${_size}x${_size} -format jpg -quality 75 -path thumbs *.jpg
##########################
#
# overview jun 25
# * doing on ANDROID
# * 2.5 GB -> ? 100MB = 25x smaller
# * started 1803 ... 1808 ... around 5min
# * TODO : THERE IS NO PROGRESS BAR !!!!
#
#
#
# PROGRESS BAR
#
# ls | grep jpg | wc -l
#
#fail
#function PROGRESS {
# ls | wc -l
#}
# TODO !!!!!!!!! NOW jun26
#_total=$(find | egrep '(\.jpg)|(\.JPG)' | wc -l)
_lol=$(__find_count "jpg")
_total=$(__find_count "jpg|mp4")
_all="$_lol"
#watch "echo Images/Images+Videos : $_lol/$_total" #/$_total <-- ow yeah"
#
#
# DIFFERENCE
# Ok, I made thumbs before
# Don't do the same ones again??!
#
#
#
# TIME FAILS
# Compare names + EXIF data ?!
# no no, that won't work ...
#
#
##########################
echo
cowsay "Create thumbs"
echo "Max edge ${_size}px, q=${_q}, destination folder '$_dest'" | __color
__confirm
echo
mkdir "$_dest"
echo
echo "Doing *.jpg" | __color
mogrify -scale ${_size}x${_size} -format jpg -quality $_q -path "$_dest" *.jpg &
mogrify -scale ${_size}x${_size} -format jpg -quality $_q -path "$_dest" *.JPG &
mogrify -scale ${_size}x${_size} -format jpg -quality $_q -path "$_dest" *.png &
#possible improve
#1) -adjoin / -mosiac : ..... OK THIS WOULD BE BAD -- GALERIES NEED TO BE DONE AT FRONTEND LEVEL RIGHT
#2) caption / label images (for example with assigned tags)
#3) DO NOT OVERWRITE (leave existing thumbs alone)
#4) ...
#watch -n0.1 "echo Images/Images+Videos, in $_dest : $(ls -1 $_dest| wc -l) of $_lol" #/$_total <-- ow yeah"
#watch -n0.1 "echo Images/Images+Videos, in $_dest : $(ls -1 $_dest | wc -l) of $_lol" #/$_total <-- ow yeah"
#watch -n0.1 "ls 0thumbs | wc -l"
watch -c -n0.1 "__progress_bar $_dest $_all"
# WATCH -c has color YAY
#echo
#echo "Doing *.JPG" | __color
#mogrify -scale ${_size}x${_size} -format jpg -quality $_q -path "$_dest" *.JPG
echo
echo