Gimp-Forum.net
Batch Crop Folder - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Installation and usage (https://www.gimp-forum.net/Forum-Installation-and-usage)
+--- Thread: Batch Crop Folder (/Thread-Batch-Crop-Folder)



Batch Crop Folder - Poorman65 - 07-11-2021

I have a collection of png images that are rendered for an animation. I need to crop them down to 1920x1080, and need to be able to do it as a command that gets automatically executed when my image rendering is completed.

I'm not sure if there is a straight-forward way to simply run Gimp with options to take advantage of the built-in cropping, or if there is some reason that a separate script is required. 

I have been searching for the solution to this, but haven't been able to find something that works. It is difficult to know if the things I am finding are outdated or not. I did find a batch-crop scm that apparently should do it, but I get an error trying to run it. I've never used a Gimp script, so I may just be using it incorrectly.


RE: Batch Crop Folder - Ofnuts - 07-12-2021

For this kind of things a command-line utility such as ImageMagick is much better.


RE: Batch Crop Folder - rich2005 - 07-12-2021

A few observations

Quote:I have a collection of png images that are rendered for an animation.

Is this a one-off animation ? How many images make up the animation ?

Quote:I need to crop them down to 1920x1080

Does that mean all those images are greater than 1920 x 1080 in size ?

Quote: and need to be able to do it as a command that gets automatically executed when my image rendering is completed

Why ? You can batch crop beforehand using the Gimp batch plugin BIMP or command line ImageMagick
Cropping after assembling an animation into layers is a simple process the crop tool applies to all layers. If you try and automate this, what parameters ? Size is known but is that applied from top-left corner (origin 0,0) or from a center point which can be variable ?

Do you have several animations and want to crop all the animations in one go ?

Quote:I did find a batch-crop scm...but I get an error trying to run it. I've never used a Gimp script

Give a pointer to the script, it might be user-error or it might be old and fixable / non-fixable.

Edit: A quick search and maybe you saw something like this ? https://www.joelotz.com/blog/2020/batch-autocrop-png-images-in-gimp.html thats an autocrop but guessing what you have is similar. That is a Gimp script but it is for command line use.

If you want a GUI for use within Gimp & will crop a folder of images then BIMP https://alessandrofrancesconi.it/projects/bimp/ Not difficult to use, there are examples on the site.

Your best bet is crop everything before making the animation.

BIMP will crop an animation something.gif providing the output is specified as a gif, leave that out and the gif is flattened to one layer. It does give an error message about indexed format but still gives an animation and keeps the timings.


RE: Batch Crop Folder - Poorman65 - 07-12-2021

Quote:Is this a one-off animation ? How many images make up the animation ?
Does that mean all those images are greater than 1920 x 1080 in size ?
Do you have several animations and want to crop all the animations in one go ?
This will be part of a workflow. Most of the animations are rendered at 1920 x 1080, but some of them will be at larger sizes for which I have a still image that gets scrolled, and then an animation that plays at the end of scrolling. I would have the rendering drop down to 1920 x 1080, but I haven't found a way to do that and make the camera line up perfectly with to the top of where the larger image was aligned.

Quote:Why ? You can batch crop beforehand using the Gimp batch plugin BIMP or command line ImageMagick
Cropping after assembling an animation into layers is a simple process the crop tool applies to all layers. If you try and automate this, what parameters ? Size is known but is that applied from top-left corner (origin 0,0) or from a center point which can be variable ?
I am using Daz Studio to render a series of images for my animations. Often I have the longer animations running overnight, as they can take many hours to render. Typically these animations are from 90-240 frames at 30/sec. I am setting up scripting to take care of a few post-processing tasks that always need to be done. Daz Studio can automatically run a script for me after rendering is finished. The current usage would be from 0,0. It would nice if I could specify the origin if I need to do that for a future use.

Quote:Give a pointer to the script, it might be user-error or it might be old and fixable / non-fixable.
This is the one I found, but I don't have any need to stick with it. The title mentions 2.2 through 2.6, so maybe these wouldn't work with later gimp versions: http://www.hildstrom.com/projects/gimpscript/index.html

Quote:Edit: A quick search and maybe you saw something like this ? https://www.joelotz.com/blog/2020/batch-autocrop-png-images-in-gimp.html thats an autocrop but guessing what you have is similar. That is a Gimp script but it is for command line use.
I'll take a look at this.

Quote:Your best bet is crop everything before making the animation.
My wording may have been confusing. I am doing this on a series of images that I turn into a "webm" and a mask "webm". I need to retain any transparencies that are in the images when they are turned into videos, since I often play these videos in a layered scene. These aren't used for animation files, but are the results of rendering an animation into images.

Quote:If you want a GUI for use within Gimp & will crop a folder of images then BIMP https://alessandrofrancesconi.it/projects/bimp/ Not difficult to use, there are examples on the site.
BIMP will crop an animation something.gif providing the output is specified as a gif, leave that out and the gif is flattened to one layer. It does give an error message about indexed format but still gives an animation and keeps the timings.
I briefly looked at BIMP, but at a quick glance it looked like it was UI based, and not command line. I want this to be an automated process, so I can't use something that has a UI

This is the first post-processing task that I am trying to automate. There are other things I would like to be able to do as well. ImageMagick may be a good way to go. When I saw that mentioned in this forum, I thought it might be an attempt to pitch an alternative to Gimp. A lot of times I see commercial products trying to make sales in this way. I just checked and I see that this is a free tool. I would like to keep my tools to a minimum, but if this is a better option for these command line tasks that I need to do, then I will try it out.


RE: Batch Crop Folder - rich2005 - 07-12-2021

Imagemagick is probably your best bet.
There is extensive documentation example https://legacy.imagemagick.org/Usage/crop/
The best place to ask specific questions is their forum https://github.com/ImageMagick/ImageMagick/discussions Very helpful there.


RE: Batch Crop Folder - Poorman65 - 07-12-2021

Thanks! I'll check out Imagemagick