I have some 1080x1920 png files and I want to crop them into 1080x1728 with offset-y 65, so I tried and it returns this:
gimp -i -b '(gimp-image-crop "*.png" 1080 1728 0 65)' -b '(gimp-quit 0)'
$ ll
total 1796
drwxrwxr-x 2 cat cat 4096 Jul 25 15:06 ./
drwxrwxr-x 4 cat cat 4096 Jul 25 14:37 ../
-rwxrwxr-x 1 cat cat 278356 Jul 9 10:56 1.png*
-rwxrwxr-x 1 cat cat 278356 Jul 9 10:56 Screenshot_20210709-105437.png*
-rwxrwxr-x 1 cat cat 58088 Jul 9 10:56 Screenshot_20210709-105445.png*
-rwxrwxr-x 1 cat cat 108385 Jul 9 14:54 Screenshot_20210709-145331.png*
-rwxrwxr-x 1 cat cat 130486 Jul 9 22:18 Screenshot_20210709-221631.png*
-rwxrwxr-x 1 cat cat 133602 Jul 9 22:20 Screenshot_20210709-221834.png*
-rwxrwxr-x 1 cat cat 153976 Jul 9 22:22 Screenshot_20210709-222035.png*
-rwxrwxr-x 1 cat cat 149365 Jul 9 22:23 Screenshot_20210709-222039.png*
-rwxrwxr-x 1 cat cat 124369 Jul 11 17:01 Screenshot_20210711-165959.png*
-rwxrwxr-x 1 cat cat 138719 Jul 24 23:06 Screenshot_20210724-230338.png*
-rwxrwxr-x 1 cat cat 88272 Jul 24 23:06 Screenshot_20210724-230346.png*
-rwxrwxr-x 1 cat cat 104779 Jul 24 23:06 Screenshot_20210724-230356.png*
-rwxrwxr-x 1 cat cat 63867 Jul 24 23:05 Screenshot_20210724-230408.png*
$ gimp -i -b '(gimp-image-crop "*.png" 1080 1728 0 65)' -b '(gimp-quit 0)'
batch command experienced an execution error:
Error: Invalid type for argument 1 to gimp-image-crop
$
It always returns Invalid type for argument 1 to gimp-image-crop
.
I check in Procedure Browser in GIMP and it tells:
The argument 1 is "THE IMAGE". I also tried "1.png" and ".+png" but it always returns the same error: Error: Invalid type for argument 1 to gimp-image-crop
I don't understand which part I do wrong.
My OS is Linux Mint 20.2 Cinnamon and GIMP version is 2.10.18.
Please help.
The image
argument of gimp-image-crop
is the handle of a loaded image in Gimp, not an image file. So you have to gimp-file-load
the image (this gives you a handle), apply your operations, and then gimp-file-save
. Note that saving an image to a "flat" format (JPG, PNG...) is actually saving a layer, so if your image is more than one layer you may have to first create a layer to save using gimp-layer-new-from-visible
.
This said, agreed that in most cases it is faster to use ImageMagick.