Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Thursday, September 14, 2017

Reducing image quality with GIMP in batch mode

Recently I got some photos and I needed to reduce its quality. I was able to open an image in GIMP. and by following the following menu I can reduce the image quality

File --> Export As... --> (choose file name) --> Export --> (select quality) Export



This is fine for a single image. But when there are lot of images it is not easy to open one by one and reducing its quality.

This is where the GIMP's batch mode processing helps a lot.

First we define a function which contains all the needed procedures. and save the script in

~/.gimp-2.8/scripts

with .scm extension.

To view all the procedures and its parameters, go to
Help --> Procedure Browser

Now call the function as follows
gimp -i -b '(<function name> <arguments>)' -b '(gimp-quit 0)'


Following is a sample of reducing the image quality.
(define (batch-reduce-img-quality pattern quality)
  (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))))
                                  (file-jpeg-save 1 image drawable filename filename quality 0 1 1 "" 0 1 0 0)
(gimp-image-delete image))
           (set! filelist (cdr filelist)))))

once the above script is saved in  ~/.gimp-2.8/scripts with .scm extension (any name)

enter the following command to reduce the image quality from the directory which contains the images.
IMPORTANT: this is overwrite the original image with the reduced quality image.


gimp -i -b '(batch-reduce-img-quality "*.JPG" 0.5)' -b '(gimp-quit 0)'

The above command will reduce the quality of the images available in the directory to 50% 

Saturday, September 3, 2016

How to setup a local SVN server

Following commands guide to set a local SVN server, this is helpful when you want to use a temporary SVN sever (eg: testing a cluster setup)

Creating the repository

(go to the desired path where you want to setup the repository)
svnadmin create <repository-name>

Setting up username and password

uncomment the following in <repository-name>/conf/svnserve.conf
  • anon-access = none
  • auth-access = write
  • password-db = passwd 
add the users in the <repository-name>/conf/passwd in the following format 
username = password 

Starting the SVN server 

svnserve -d -r <repository-name>

svn server will start on the default port 3690

Checking out the repository 

svn co svn://localhost/

Committing a file 

svn ci -m "adding hello file" hello.txt --username username --password password

Stopping the svn server

ps -ef | grep [s]vnserve | awk '{print $2}' | xargs kill -9