msgbartop
A cronological documentation test project, nothing serious, really!
msgbarbottom

02 Feb 2008 Extracting images from Adobe Acrobat PDF file

This is a short example of how to extract images from a PDF file using ImageMagick

# convert thePDFfile.pdf page-%03d.png
# ls page*
page-000.png  page-001.png  page-002.png

Imagemagick can also be used to create Adobe Acrobat PDF documents

convert DSC* resultFile.pdf

The resultfile contains one image per page.

Tags: , ,

Posted by Hans-Henry Jakobsen

30 Dec 2007 Resize and watermark images using Imagemagick

Tina resizedThis is a modified version of my Resize of images in a folder with imagemagick post back in February. Only difference this time is that i strips out EXIF tags and the script has been cleaned up a bit. Click on the image to see the result in full size.

#!/bin/bash

# Description:
# Script to resize JPG images to desired width defined in IMAGESIZE variable.
# EXIF tags is also removed from the result images.
# Software needed:
# jhead - http://www.sentex.net/~mwandel/jhead/
# imagemagick - http://www.imagemagick.org

IMAGESIZE="320 480"
for IMAGEFILE in $(ls|grep JPG)
do
        for I in $IMAGESIZE
        do
                # create directories if needed
                if [ ! -d $I ]
                then
                        mkdir $I
                fi

                # Strip EXIF tag information from source file
                jhead -purejpg $IMAGEFILE

                # Resize file
                base=`basename $IMAGEFILE .JPG`_Resized_$I.JPG
                convert $IMAGEFILE -resize $I $base

                # Watermark the file
                width=`identify -format %w $base`
                convert -background '#0008' -fill white -gravity center -size ${width}x15 \
                -font Verdana -pointsize 10 \
                caption:"Copyright © 2007 Pario.no" \
                +size $base +swap -gravity south -composite $I/$base;

                # delete resized file
                rm $base
        done

        # Delete source file (DO NOT USE YOUR ORIGINAL FILE!)
        rm $IMAGEFILE
done

You can download my resize, watermark bash script here.

Tags: , , ,

Posted by Hans-Henry Jakobsen

25 Nov 2007 Adjust images to a digital frame (480×234 pixels)

This bash script adjusts images to fit in a digital frame with a resolution of 480×234 pixels however by using the size 832×468 pictures are displayed sharper on some frames. Normally, narrower pictures will have black borders at both sides when displayed. but this script makes the border color the average of the picture.

The following linux tools are used in the script: convert and montage, bash, od and awk. od is part of the textutils package in Debian.

#!/bin/bash
# current directory contains source JPG files
# $DESTINATION is where the prepared JPG files are stored
# $TEMP is a temporary directory
TEMP=TEMP
DESTINATION=DESTINATION
GEO=832x468 # geometry of target JPG files and resize value

for FILE in *.JPG
do
convert -resize 1x1 "$FILE" "$TEMP/1x1.bmp"
od -A n -j 54 -t u1 "$TEMP/1x1.bmp" | awk -v f="$FILE" -v des="$DESTINATION/" -v geo="$GEO" '
{
print "montage -geometry", geo, "-resize", geo, "-background rgb\\(" $3 \
"," $2 "," $1 "\\) \"" f "\" \"" des f "\"";
exit;
}'

done | sh -x

Source: comp.graphics.misc

Tags: , , , , ,

Posted by Hans-Henry Jakobsen

25 Nov 2007 Great collection of advanced Imagemagick scripts

Today I stumbled upon Fred’s Imagemagick Scripts, a nice collection of bash scripts to do image manipulations like

  • 3D rotate
  • change/enhance brightness
  • Superimposes a set of horizontal and/or vertical grid lines on an image
  • etc…

    Tags: ,

    Posted by Hans-Henry Jakobsen

    25 Nov 2007 Create a photo montage using imagemagick

    This is a little bash script I put together to create a photo montage with 5 resized pitures in max 3 rows using imagemagick. The script is run from within the folder I have filled with the JPG images I want to create a montage from.

    #!/bin/bash
    for image in `ls *.JPG`
      do
        convert -resize 50x50! $image small-$image
      done
    montage small-*.JPG -mode Concatenate -tile 5x3 montage_final.jpg

    The result file like the one below is saved with the filename montage_final.jpg.
    Montage finalOne disadvantage using this technique is that it doesn’t keep the aspect ratio of the pictures.
    You find more examples of montage usage by visiting the ImageMagick v6 Examples — Montage, Arrays of Images page.

    Tags: , , , ,

    Posted by Hans-Henry Jakobsen