Showing posts with label useful. Show all posts
Showing posts with label useful. Show all posts

Monday, July 2, 2012

Miniature Photo Album with ImageMagick (montage, convert) and Some Shell Scripting

How to develop photos smaller than 13x9, 15x11...

The fork is just there to indicate the size of the photos
When ordering photos online, you usually have the option to choose between formats like 13x9cm, 15x11cm, etc. However, none of these digital photo online services (that I know) offers smaller sizes. This post describes how to easily "merge" 4 JPG files into a big one (containing these 4 files in a 2x2-grid), which you can then order online and cut with scissors (or your other favorite cutting device) in order to create an album with photos of the size 7.5x5.5cm (or smaller, by adjusting some parameters)

Important: The shell script shown below does not touch the original files (it copies and rotates them). However, I don't give any warranty that you don't lose or ruin your original files, so make sure to have a backup!

Prerequisites

  • A set of JPEG images (optimally the same aspect ratio in order to get a seamless montage)
  • An installation of ImageMagick (the executables have to be in the $PATH)
  • A bash-terminal

How to do it

  • Move all the JPG files in a directory
  • cd into this directory and create an executable script with the content from below
  • Execute the script and wait
  • After that, the subdirectory generated contains the files you might want to upload to your online photo service  


#!/bin/bash

g=generated
t=$g/tmp

mkdir -p $t

### STEP 1 - cloning/rotating the file to 'portrait' 
### into the temporary subdirectory(0.jpg, 1.jpg, etc.)
i=0
IFS=$'\n'
for file in `find . -type f -iname "*.jp*g"`
do
 echo "rotating file $file into $t/$i.jpg"
 convert "$file" -rotate '90>' $t/$i.jpg

 let i=i+1
done


### STEP 2 - take 4 JPG files at a time 
### and compile them into new 2x2-images 
i=0
nroffiles=`ls $t/*.jpg | wc -w`
let nrofiterations=nroffiles/4
while [ $i -lt $nrofiterations ] 
do
 ## helper variables to access file names
 let f=i*4
 let a=f+0
 let b=f+1
 let c=f+2
 let d=f+3
 echo "creating a$i.jpg ($a.jpg $b.jpg $c.jpg $d.jpg)"

 ## compile the 4 separate images into a 2x2-grid. 
 ## please change the parameter 768x1024 if you 
 ## don't have a 3:4 aspect ratio
 montage $t/$a.jpg $t/$b.jpg $t/$c.jpg $t/$d.jpg -tile 2x2 -geometry 768x1024 $g/a$i.jpg
 let i=i+1
done

### remove the tmp directory
rm -rf $t



The images created by this script look somewhat like this one (individual pictures taken from http://www.freeimages.co.uk/)


Not very advanced stuff, I know, but I think it's a nice combination of some handy tools to make a nice present.

P.S. 1: I know that there are more elegant ways to write the shell-script, but for my purposes and skills this was the quickest way to go.

P.S. 2:  I think the 7.5x5.5cm format is optimal for a flip book. Wouldn't it be easy and fun to create your own flip book story with the continuous shooting mode of your digital camera?

Friday, April 6, 2012

ImageUploader as Java Web Start

In older blog posts I reported about my ImageResizer/Uploader appplication.
A while ago I turned it into a Java Swing application, startable via Java Web Start.

Short description
It's a tiny but very useful software to resize and upload a bunch of JPG-files to a Google Picasa Web Album. It´s perfectly suitable for travellers in countries with slow Internet connections. The idea behind this software is the following: A full-sized JPG files on a digital camera with (let´s say) 3 MB has only 300 KB if it is resized to 70% of its original size, but has (nearly) the same quality. So Internet-backups can be made 10-times as fast.

You can find it here:
https://sites.google.com/site/dbimageuploader/home

Please don't forget to read the "Background" section:
https://sites.google.com/site/dbimageuploader/background

Monday, January 24, 2011

CropPDF integrated in Nautilus

During my master thesis I had to perform the following task several times: crop a PDF, i.e. remove the outer white borders of the PDF.

A software called pdfcrop (I think it is in the Ubuntu repositories) can do this. From a console the syntax is the following:

pdfcrop input.pdf output.pdf

I wanted to use this feature from my file browser (Nautilus), by right-clicking the file-to-be-cropped and choosing "Scripts -> Crop PDF". Here is how to do this:
  • Create a file called CropPDF located at ~/.gnome2/nautilus-scripts with the following content
  • #!/bin/bash
    pdfcrop $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS \
            $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
  • Make it executable (chmod +x CropPDF)
  •  
That's it.
Caution: this modifies the file, on which you execute the operation!

Portable Apps - PortableApps.com

Today I found a very useful web page: http://portableapps.com/
It provides (freeware, free and open source) software, that can be carried on a portable device and can be used on any Windows computer.

This seems to be optimal for my journey, because Internet cafés will mostly operate on Windows machines, and I won't have the rights to install software.

Saturday, January 22, 2011

E-Mail Obfuscation

This blog shows nine ways to obfuscate e-mails
See the HTML source of this page to see the internals.

One of the easiest "rock-solid" methods, that do not earn spam is the following:

<style type="text/css">
span.codedirection { 
  unicode-bidi:bidi-override; 
  direction: rtl; 
}
</style>

<span class="codedirection">
moc.oof@leinad
</span>

This produces daniel@foo.com.


This is the other "easy" way:

<style type="text/css">
span.displaynone { display:none; }
</style>

daniel@<span class=”displaynone”>null</span>foo.com