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
Now call the function as follows
Following is a sample of reducing the image quality.
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.
The above command will reduce the quality of the images available in the directory to 50%
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%