.

Monday, March 4, 2013

Bash script for auto editing all jpeg files in directory using GIMP on Linux

#!/bin/bash

# UNSHARPMASK+AUTO WHITE+VIVID SATURATION

$wm = "iip.umar.rifai@gmail.com"
if [ "$3" != "" ]; then
    $wm = "$3"
fi

mkdir small
for ip in $(ls *.jpg *.JPG)
do
  echo ------------------------------------------------
  echo "$ip"
  cp -f "$ip" "./small/$ip"
  gimp -idf --batch-interpreter=python-fu-eval -b "from gimpfu import *;infile=\"./small/${ip}\";outfile=\"./small/${ip}\";image = pdb.gimp_file_load(infile,infile);drawable = pdb.gimp_image_get_active_layer(image);pdb.script_fu_auto_contrast(image, drawable, 1, 0);drawable = pdb.gimp_image_get_active_layer(image);pdb.script_fu_contrast(image, drawable, 20, 80);pdb.gimp_image_flatten(image);drawable = pdb.gimp_image_get_active_layer(image);pdb.script_fu_vivid_saturation(image, drawable, 10);pdb.script_fu_EZRedSkinFix(image, drawable,35,1);drawable = pdb.gimp_image_get_active_layer(image);pdb.plug_in_unsharp_mask(image, drawable, 5.0, 0.5, 0);drawable = pdb.gimp_image_get_active_layer(image);down=float(${1});aspect,down_w,down_h=[float(image.width)/float(image.height), (down if image.width>down else None) if image.width>image.height else (down*float(image.width)/float(image.height) if image.height>down else None),(down/(float(image.width)/float(image.height)) if image.width>down else None) if image.width>image.height else (down if image.height>down else None)];pdb.gimp_image_scale(image, down_w, down_h);tratio = float(image.width)/4000;pdb.gimp_image_flatten(image);drawable = pdb.gimp_image_get_active_layer(image);pdb.file_jpeg_save(image, drawable,outfile,outfile, float(${2})/100, 0, 1, 1, \"\", 1, 0, 0, 0);pdb.gimp_quit(0)"

#text_layer = pdb.gimp_text_layer_new(image, '${wm}', 'DejaVu Serif Condensed', 120*tratio, 0);pdb.gimp_image_add_layer(image, text_layer, ((image.width*tratio)-(100*tratio)-(1686*tratio), (image.height*tratio)-(10*tratio)-(140-tratio)));pdb.gimp_image_set_active_layer(image, text_layer);pdb.gimp_text_layer_set_color(text_layer, (220,202,53));pdb.gimp_layer_set_opacity(text_layer, 20);
#= pdb.gimp_text(image, drawable, (image.width*tratio)-(100*tratio)-(1686*tratio), (image.height*tratio)-(10*tratio)-(140-tratio), '${wm}', 0, 1, 120*tratio, 0,'DejaVu Serif Bold Italic Semi-Condensed', 'Serif Bold Italic', '', '', str(141*tratio), '', '', '')
##  convert -scale $1 -quality $2 "./small/$ip" "./small/$ip"
  if [ "$3" == "" ]; then
     convert -size 350x60 -background none -font "Times-bolditalic" -pointsize 20 -gravity center caption:"iip.umar.rifai@gmail.com" -shade 240x40 ___txt.png
     composite -watermark 40% -gravity "southeast" ___txt.png "./small/$ip" "./small/$ip"
  else
     convert -size 350x60 -background none -font "Times-bolditalic" -pointsize 20 -gravity center caption:"$3" -shade 240x40 ___txt.png
     composite -watermark 40% -gravity "southeast" ___txt.png "./small/$ip" "./small/$ip"
  fi

No comments:

Setting DeepCool AK400 Digital CPU fan di Manjaro Linux

  Baru rakit PC dan pakai AK400 Digital untuk CPU fannya, setelah install linux ternyata tulisan digitalnya gak tampil, cari-cari di interne...