Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Saturday, January 2, 2010

Batch Resize Images in GIMP

It is always required to resize a set of images at once. So that, no need to do it one by one. Let's see, how this can be achieved using GIMP image editor in Ubuntu.

We are using the batch mode of GIMP to do image processing from the command line. Let's write a simple script in Scheme language to resize a set of image files.

(define (batch-resize pattern width height)
(let* ((filelist (cadr (file-glob pattern 1))))
(while (not (null? filelist))
(let* ((filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
(gimp-image-scale-full image width height INTERPOLATION-CUBIC)
(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
(gimp-image-delete image))
(set! filelist (cdr filelist)))))

This particular script takes a pattern for filename, desired width and height as inputs and resize all image files that are matched. This script overwrite the existing file. In order to run the script, save it with .scm extension in the ~/.gimp-/scripts/ directory.
Then goto the directory which contains images, then run the following command to resize images.

gimp -i -b '(batch-resize "*.JPG" 604 453)' -b '(gimp-quit 0)'
The above command will resize all the image files end with .JPG to 604X453
The above script can be customized to any other image processing requirements as well. Refer the Help -> Procedure Browser in GIMP for more operations.

The following script rename the resized image file by adding 'a' to the beginning of the file name

(define (batch-resize-rename pattern width height)
(let* ((filelist (cadr (file-glob pattern 1))))
(while (not (null? filelist))
(let* ((filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
(gimp-image-scale-full image width height INTERPOLATION-CUBIC)
(let ((nfilename (string-append "a" filename)))
(gimp-file-save RUN-NONINTERACTIVE image drawable nfilename nfilename))
(gimp-image-delete image))
(set! filelist (cdr filelist)))))

By referring to the GIMP procedure and plugins browser and a Scheme tutorial, it is possible to customize the above script as required.

References:

Tuesday, August 4, 2009

Installing Amarok in Ubuntu 9.04

There are problems in Amarok 2.0 in Ubuntu :(
Only work around is to use Amarok version 1.4
Therefore,
sudo apt-get install amarok

does not work. Instead use
sudo apt-get install amarok14

For further details refer - http://nomad.ca/blog/2009/apr/3/amarok-14-jaunty-ubuntu-904/

Wednesday, June 24, 2009

Sign in to yahoo by PIDGIN

These days Pidgin does not allow to connect to yahoo. It is due to some maintenance or upgrade of their servers. This is a really annoying experience to pidgin-yahoo users. The simple solution is to upgrade the Pidgin version to 2.5.7 (newest). the instructions are given in the pidgin site.

Tuesday, June 9, 2009

Disk Partition strategy for Ubuntu

A newie-bee to Ubuntu may tend to install it in to a single partion ("/"). But it is always advisable to create few more partitions in order make our lives easier, when it is required to re-install Ubuntu as well as when you required to retain the user accounts, their configuration and the softwares insatalled.
In order to achive this, it is required to create atleast another home partition ("/home"). According to the interest, a "/opt" partion can be created in order to install softwares.
Say, You have to re-install Ubuntu due to a inevitable reason, then it is only require to format the root ("/") partion only, other partions can be left intact. You required to create the same user accounts to activate the old user accounts.
In this way, it is possible to re-install Ubuntu without wasting much to configure it again.

Saturday, May 23, 2009

Add multiple jars to classpath

In java (in UNIX like platform), it is not enough just to include the directory, in which the jar dependencies of your application reside, to the classpath. It is required to include path of each and every dependant jars to the classpath. If your application only depends on few jars this is not a problem. But, what if your application depends on several jars say 20, it will be an annoying task to add all the paths of jars to the classpath manually.
It is possible to use a simple shell script to accomplish the above mentioned task. The script can be customized to suit your application very easily.


export JAR_HOME=path to directory which includes jars

for f in $JAR_HOME/*.jar

do

JAR_CLASSPATH=$JAR_
CLASSPATH:$f
done

export JAR_CLASSPATH


#the next line will print the JAR_CLASSPATH to the shell.
echo the classpath $JAR_CLASSPATH


java -classpath $JAR_CLASSPATH Name of the programme

Say your jars are in several diferent folders, then you will have to use a for loop per each directory and finally concaternate to a single variable.