Showing posts with label convert. Show all posts
Showing posts with label convert. Show all posts

Friday, 24 July 2009

Bulk rotate images using EXIF data

Using a simple command line command it is very simple to rotate any number of images using the exif data (hopefully) contained in the image. Most cameras will save the exif data and include the camera rotation when the photograph was taken.

sudo apt-get install jhead

then when we run the following command in the folder it will losslessly rotate the photographs that need it.

jhead -autorot *

Job done :]

Monday, 15 June 2009


How to read 20 magazines for free.


You will need Firefox and an addon called User agent Switcher and configure it with an iPhone setting :

Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A102 Safari/419 (United States)

You can then visit http://zinio.com/iphone/ and read 20 magazines each month for free.

It gets better though, it is very simple to download these pages onto your computer using Linux, aren't you glad you dumped windows ;)

We now need the URL to the image so "copy image location" from the right click menu then using this command:

curl -O -A "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A93 Safari/419.3" INSERTURL

Replace INSERTURL with the copied link you got to page 1, then delete back to the underscore and append [1-300].jpg this is a range option to grab pages 1 to 300 and can be adjusted, so the final command will look like this:

curl -O -A "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A93 Safari/419.3" http://imgs.zinio.com/iphone/issues/416078746/[1-300].jpg

The files will need to be renamed, as sadly they won't sort correctly if you are going to do the next step of combining them into a single pdf. We need the jpgs numbering from 001.jpg so they order correctly. this can be achieved in a variety of ways, using Thunar rename to insert the necessary 0's in two stages is one simple way, insert 00 at position 10 for number 1-9, and insert 0 into postion 10 for pages 10-99. it can also be scripted in a couple of steps with :

for i in `seq 1 9`; do mv *_$i.jpg 00$i.jpg ;done

for i in `seq 10 99`; do mv *_$i.jpg 0$i.jpg ;done

This could of course be scripted into one single command using a bash script.

Then we can simply issue the command:

convert *.jpg magazine.pdf

Thats it, you now have a local copy of the magazine in a handy PDF format relatively simply, it lokos more complex than it really is once you get your head around it.

Tuesday, 23 September 2008

Convert BIN/CUE Images to ISO

Convert bin/cue into ISO

Installation

sudo apt-get install bchunk

Usage As the name implies, a BIN/CUE CD image has two files. BIN being a binary of the raw CD data, and CUE being an ASCII file of CD layout.General usage:

bchunk
image.bin image.cue basename

For example:

bchunk myimage.bin myimage.cue myimage

Where basename(myimage) is myimage.iso of the produced file.

Sunday, 31 August 2008

Use exiftran to transform jpeg images

Exiftran is a command line utility to transform digital image jpeg images. It can do lossless rotations like jpegtran, but unlike jpegtran it cares about the EXIF data: It can rotate images automatically by checking the exif orientation tag, it updates the exif informaton if needed (image dimension, orientation), it also rotates the exif thumbnail. It can process multiple images at once.

exiftran -ai *

This will transform all the images in a folder, rotating them to the correct orientation as defined by the exif data from the camera and replace the original, assuming your camera can sense and write the orientation into exif data.

exiftran -i9 *

Transform the image through 90degrees (to the right) and overwrite the original.

exiftran -i2

Transforms the image through 270degrees (to the left) and overwrite the original.

I have adapted this into two scripts in my nautilus-scripts folder "/home/subbass/.gnome2/nautilus-scripts/" you can make two scripts in this place using the following code and just changing the exiftran command to rotate left or right in each of the scripts.

#!/bin/sh
for arg; do
filetype=`file -i "$arg"`
if [ -n "`echo $filetype | grep -i '.jpg' `" ]; then

exiftran -i9 "$arg"

else
convert -rotate 90 "$arg" "$arg"
fi
done

The convert at the end is to convert other image formats without me requiring another set of scripts, feel free to omit this if desired. Always do a small test before setting any script to work on large numbers of images, I don't want to be held responsible if your exif data gets nuked.

Thursday, 14 August 2008

Use convert to add a border to multiple images in the command line

Ok, so you you have taken a bunch of photos with your new camera and what do you know, some of them are half decent. I use this after I have copied photo's I want to print or photo's that I am sending to flickr or deviant art to a seperate folder as it really adds a finishing touch, I copy them to a seperate location so I know exactly which ones I am printing/uploading and don't omit any.

Now you could easily do this in The Gimp, load each image and enlarge the canvas followed by a fill and then resave the image. This is linux though and we can do things a heap simpler than that!
First install Imagemagick:

sudo apt-get install imagemagick


Or install it via Synaptic or your package manager.

Then use this simple script,

be aware that you should operate on copies as this does overwrite the original, as noted above I only do this on photo's I have copied for printing/uploading.


for img in `ls *.jpg`

do
convert -bordercolor white -border 50x50 $img $img
done

Easiest to pop it all into a bash script, or just close it up separating the commands with semicolons into a one liner eg.

for img in `ls *.jpg` ; do ; convert -bordercolor white -border 50x50 $img $img ; done

If your camera uses a different extension then adjust the .jpg accordingly.

Adjust "50x50" to whatever you feel adds a nicely sized border, and feel free to change the border colour (black for instance). If you want to get creative stack up the converts to add a thin black border before a larger white border or whatever you fancy.