55

As implied by the title, does anybody know how to use the gimp-console-[version].exe program to batch convert images between formats (with default settings) in Windows ?

9 Answers 9

61

Better than Gimp or Irfanview is ImageMagick.

For instance, try:

mogrify -format jpg *.png
11
  • 2
    Also mogrify will overwrite the original images, use convert to make new files in the desired format. Dec 1, 2009 at 19:20
  • 1
    Please be aware, that in many cases Gimp generates smaller images than imagemagick, so if you are going for size, check gimp batch mode as well.
    – Krystian
    Jul 25, 2013 at 8:10
  • 5
    If you only need to do this rarely and have Gimp installed for image editing anyway but don't have ImageMagick installed then doing this with Gimp makes perfect sense. Also if you don't have permissions to install software. Feb 9, 2014 at 16:14
  • 2
    @DaveParillo In this case it's not. quote: unless you change the file suffix with the -format option imagemagick.org/script/mogrify.php
    – mrgloom
    Mar 20, 2017 at 15:26
  • 1
    seems to work, but for the latest version it's all included in one tool so the command line is magick mogrify -format jpg *.png. Also, despite saying it added itself to the path variable it didn't seem to work without going to the specific install folder.
    – Nyerguds
    Dec 4, 2017 at 10:04
9

Put the following in ~/.gimp-<YOURVERSION>/scripts/myconvert.scm:

(define (myconvert in_filename out_filename)
    (let* (
            (image (car (gimp-file-load RUN-NONINTERACTIVE in_filename in_filename)))
            (drawable (car (gimp-image-get-active-layer image)))
        )
        (gimp-file-save RUN-NONINTERACTIVE image drawable out_filename out_filename)
        (gimp-image-delete image)
    )
)

Then, you can run something like this to convert all the files in the current directory to JPGs:

for A in * ; do gimp -i -b "(myconvert \"$A\" \"$A.jpg\")" -b '(gimp-quit 0)' ; done
1
  • For me (running Debian GNU/Linux), the folder was ~/.config/GIMP/2.10/scripts. Oct 25, 2021 at 11:57
6

There is also a wizard based batch processor available:

DBP (David's Batch Processor) for GIMP

enter image description here

3
  • I've tried so many different ways to batch convert a bunch of DDS files to another file format, and this is the only way that's worked. Thank you so much! Mar 19, 2011 at 16:19
  • 1
    There's also bimp (registry.gimp.org/node/26259) Apr 8, 2015 at 9:33
  • This doesn't seem to work anymore, nothing happens when I copy this to the plug-ins folder. Also, the link to the website on SourceForge is dead. Jul 4, 2022 at 1:58
4

Is using Irfanview not an option? I keep both GIMP and Irfanview installed for precisely this reason...GIMP for image editing and Irfanview for batch conversion.

3
  • 3
    Irfanview is named for its author, Irfan Skiljan. Irfanview is pronounced "EarfanView". See irfanview.com/main_about.htm for more.
    – eleven81
    Dec 1, 2009 at 17:34
  • 1
    There's this to keep in mind for Irfanview, though: "IrfanView is provided as freeware, but only for private, non-commercial use (that means at home). IrfanView is free for educational use (schools, universities, museums and libraries) and for use in charity or humanitarian organisations. If you intend to use IrfanView at your place of business or for commercial purposes, please register and purchase it." irfanview.com/eula.htm Mar 27, 2015 at 14:59
  • Unfortunately, it looks like this is only available on Windows. Jul 4, 2022 at 1:59
2

does anybody know how to use the gimp-console-[version].exe program to batch convert images between formats (with default settings) in Windows ?

The gimp-console-[version].exe uses a language called "scheme" for command interpretation. Scripts often are found ending in the .scm extension.

Scheme's hard to batch to the console due to nuances with quotes as can be observed here, but it's possible.

Here's an example which converts all .svg files in the current directory to .png files using batch. It also will look in the registry for the Gimp executable and calculate the path to the command-line version.

@echo off

set resolution=72
set width=400
set height=600

REM Find Gimp in the registry
for /f "tokens=2*" %%a in ('reg query "HKCR\GIMP2.svg\shell\open\command" /ve 2^>^&1^|find "REG_"') do @set gimp=%%b

REM Calculate console exe
set gimp=%gimp:gimp-=gimp-console-%

REM Isolate exe
for %%i in (%gimp%) do (
    @set gimp=%%i
    goto :found
)

:found
echo Found Gimp console: %gimp%

REM Process files (change to "for /r %%i" for recursion)
for %%i in (*.svg) do (
    echo - Converting [ %%i --^> %%~ni.png ] ^(%width%x%height%@%resolution%^)
    %gimp% -i -b "(let* ((image (car (file-svg-load RUN-NONINTERACTIVE \"%%i\" \"\" 72 (- 0 400) (- 0 600) 0))) (drawable (car (gimp-image-get-active-layer image)))) (plug-in-autocrop RUN-NONINTERACTIVE image drawable) (gimp-file-save RUN-NONINTERACTIVE image drawable \"%%~ni.png\" \"%%~ni.png\") (gimp-image-delete image))" -b "(gimp-quit 0)"
)

Note, this final command line can be adopted to other platforms by using single quotes around the entire scheme command and using bare double-quotes within. Tested on Gimp 2.10.18, 2.10.14.

This answer uses code extraced from a .scm file from a web-archived article from Matthew Gates 2014 titled "Gimp SVG to Raster Script".

2

I'd suggest BIMP , an EXCELLENT GMIP plugin, with powerful Batch image manipulation function and brief UI.

1

Here is Windows GUI to perform batch modifications on images (including file format conversion)

http://www.imagebatch.org/

Hope that helps someone out there!

1
  • This will not convert from PSD
    – Tom Ruh
    Mar 24, 2018 at 21:47
0

I am going to fall into the camp of using the right tool for the job and I have both Irfanview, and ImageMagick installed, and agree that both are fantastic tools. However let me throw in one more option for posterity. I don't use XnView on a regular basis, but keep a copy of the portable version around to keep on my usb so that I have a powerful easy to use very capable image tool available when I'm out and about. The beauty of the portable version is that you can use it and if you don't like it just delete the install directory. It along with dozens of other free and open source portable applications is available at http://portableapps.com/ or specifically http://portableapps.com/news/2009-12-06_-_xnview_portable_1.97 The installer will create a directory that contains everything necessary to run the program. Just go to that directory, start the EXE, give it a test. As stated above, when you get tired of it just delete the whole directory. They all run just like that from a USB stick as well. I have about 80 apps I carry around with me and use on public or shared PC's.

1
  • 1
    Similar to Irfanview, XnView has some usage restrictions: "XnView is provided as FREEWARE (NO Adware, NO Spyware) for private or educational use (including non-profit organizations)." - see xnview.com/en/xnview Mar 27, 2015 at 15:02
0

Although I am not really answering the question here I have alternative solution that has worked for me quite well and works from within the GIMP.

Keep in mind this might not be best solution for very large number of images.

Export Layers plugin for GIMP (I am not an author of this plug-in)

  • uses native dialogs for file format export procedures to adjust file format settings.
  • uses layer names as filenames for the exported images.
  • supports layer groups and optionally treats them as folders.
  • can optionally export only layers whose file extension matches specified file format.
  • can use file extensions in layer names as file formats
  • can use layers with names in [square brackets] as background layers
  1. First make sure you have GIMP 2.8 or higher (I confirm it works on 2.8.14)
  2. Download the plug-in (make sure it saves as file with .py extension)
  3. Paste the plug-in into the GIMP_INSTALLATION_FOLDER\lib\gimp\2.0\plug-ins
  4. Import your images as layers (File > Open as layers).
  5. Select File > Export Layers.. or Export Layers To
  6. Dialogue window will pop up with export options that look similar to any other GIMP dialogue window and are very self descriptive.

NOTE: If you paste the plug-in make sure GIMP is not working, if it is restart it.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .