I want to do some operation on some images using GIMP through the command line on Ubuntu. Operations that I want to do are:
- Open an image
- Convert an image to gray-scale
- Convert a PNG image to JPEG
How I can do them using the command line?
I want to do some operation on some images using GIMP through the command line on Ubuntu. Operations that I want to do are:
How I can do them using the command line?
I don't know how to use Gimp for this task, but actually I think the tools from the package
imagemagick
are better choice for such CLI tasks. This package is widely used as conversion tool on the web server's applications as MediaWiki and WordPress, also it is a back end for some operations performed by graphical apps such PhotoShop. First you need to install the package:Then use the following command to accomplish the task (reference):
If you need to convert all PNG files in the current directory you can use a loop like this:
Open an image is really easy (
image.png
is the image that you want to open)Convert RGB image to Grayscale :
Create a GIMP Script-Fu file (named here
dmmConvertPNGtoGrayscale.scm
and saved in$HOME/.gimp-2.8/scripts
) :And launch it using this script (I named it
rgbtogs.sh
for example) :Give execution to the script and start it :
Convert a PNG image to JPEG (or JPG) :
Create a GIMP Script-Fu file (named here
dmmConvertPNGtoJPG.scm
and saved in$HOME/.gimp-2.8/scripts
) :And launch it using this script (I named it
pngtojpg.sh
for example) :Give execution to the script and start it :
Source : http://beefchunk.com/documentation/lang/gimp/GIMP-Scripts-Fu.html
NB : inside GIMP Script-Fu file, you can remove all lines which begins with
;
character (or everything on the right on this character), these are just commentsNB: These
.scm
script-fu were made originally for GIMP 1.2, but I tested with GIMP 2.8 and there is no issueYou can run
gimp -h
to get the different options availabe for gimp1.Open an image
gimp -n image_name.xxx
2.Convert an image to gray-scale I have no idea if it's possible using Gimp navigate these links: https://www.gimp.org/tutorials/Basic_Batch/
https://superuser.com/questions/1334386/how-to-load-an-image-in-gimp-from-the-terminal-and-exiting-afterwards
3.convert png image to jpeg
I suggest using
convert
command line which is part of the ImageMagickconvert image1.xxx image2.yyy