![gimp batch compress images gimp batch compress images](https://www.maketecheasier.com/assets/uploads/2010/12/gimp-batch-resize.png)
Gimp –no-interface –batch ‘(python-fu-console-echo RUN-NONINTERACTIVE “another string” 777 3.1416 (list 1 0 0))’ ‘(gimp-quit 1)’ GIMP Python All this means that you could easily invoke a GIMP Python plug-in such as the one above directly from your shell using the (plug-in-script- fu-eval …) evaluator:
#Gimp batch compress images code#
The first small issue I’ve encountered in my attempt to write a batch script, is that GIMP only accepts Python code as command line argument, not the path to a script on disk. This allows for very powerful scripting capabilities. This is the nice thing about GIMP scripting: it lets you manipulate layers just like in the UI. What the code does is to take the first image from the list of open images and sets the opacity of the first layer to 50%.
![gimp batch compress images gimp batch compress images](https://i0.wp.com/digital-photography-school.com/wp-content/uploads/2021/05/batch-resize-in-Photoshop-1001.jpg)
But GIMP is actually nice, you can do many complex UI operations from code and you also have an interactive Python shell to test your code live on an image.įor example, open an image in GIMP, then open the Python console from Filters -> Python-Fu -> Console and execute the following code: img = gimp.image_list()Īnd you’ll see that the image is now halfway transparent. Of course, I could’ve tried other solutions like PIL (Python Imaging Library) which I have used in the past. Just to mention, GIMP supports also a Lisp syntax to write scripts, but it caused my eyes to bleed profusely, so I didn’t even take into it consideration and focused directly on Python. So I thought, why not using a GIMP batch command, since anyway GIMP is installed on most Linux systems by default?
![gimp batch compress images gimp batch compress images](https://uploads-ssl.webflow.com/5e9033e54576bc13f0b47167/5ef4188170820d7ad68074fd_3-1.jpeg)
One of the produced images had to be semi-transparent. To those wondering why GIMP, it’s because I created a new icon for Profiler and wanted to automatize some operations on it in order to have it in all sizes and flavors I need. You can jump to the end of the tutorial to find a nice skeleton batch script if you’re not interested in reading the theory. I spent a total of one hour researching this topic, so I’m not an expert and I could have made mistakes, but perhaps I can save some effort to others which want to achieve the same results. I won’t go into the details of the Python GIMP SDK, most of it can be figured out from the GIMP documentation. If your image is landscape-oriented, it’ll resize the width if it’s portrait-oriented, it’ll resize the height.Not a very common topic for me, but I thought it could be neat to mention some tips & tricks. Bear in mind that the scale function resizes based on aspect ratio. You should see it copy the file over and then resize it. Right click on any image, point to the “Services” option at the bottom of the context menu, and then choose “Resize”-or whatever you named your service. When you’re done, save the service and name it whatever you’d like-we’re going with “Resize.” Step Two: Put Your New Service to Use If you’d rather stick to a single size, you can leave this unchecked and type in the size you always want to use. This will make the service open a dialog asking for the image size. To make it work, click “Options” on the Scale Images service, and select “Show this action when the workflow runs.” You should now have two actions in the service. If you want to resize them in place and replace the originals, leave this copy block out. By default, the action will just make copies of the resized images and save them to the desktop (or another folder of your choice). Automator will prompt you to add a block to copy files over before resizing, which is handy to prevent accidental resizing, such as missing a 0 and losing all the image quality. In the search box at the top of the left pane, type “Scale Images” and then drag the “Scale Images” action into the main panel.