@Chintan_Gohel here’s a solution using Bash (available in Linux, macOS, and in Windows using MSYS2). It starts with the image’s full size and then subtracts a certain number of pixels from the crop width and height until the final crop size is about 1920x1080. How much gets subtracted at each step depends on the number of images - it’s calculated automatically. For every photo it creates a PP3 file with the correct crop parameters, e.g. photo123.raw will get a photo123.raw.pp3 sidecar file.
Open a raw photo in RawTherapee, enable the crop tool but leave it at full size, save a partial PP3 containing only the crop parameters to the folder with your raw files, call it crop.pp3
Save the Bash script below as rt_cropzoom, but first edit it in a text editor. All you need to do is to change *.raw to your raw file extension, e.g. if you use Nikon then change it to *.nef, and then change w=3888 and h=2608 to whatever size RT reports in crop.pp3 for W= and H=.
Open a terminal, go into the folder containing your raw files and this script, make the script executable: chmod +x rt_cropzoom and then run it: ./rt_cropzoom
Done.
The script does not handle fractions, so the final size might not be exactly 1920x1080, it could be e.g. 1926x1087
The script:
#!/usr/bin/env bash
# This script iterates over a bunch of files, setting crop parameters for each
# until a final crop size of around 1920x1080 is reached.
# Edit these:
files=(*.raw)
w=3888
h=2608
# Do not edit below this line ---
wFinal=1920
hFinal=1080
wStep=$((w - wFinal))
wStep=$((wStep / ${#files[@]}))
hStep=$((h - hFinal))
hStep=$((hStep / ${#files[@]}))
wLess=$w
hLess=$h
for f in "${files[@]}"; do
wLess=$((wLess - wStep))
hLess=$((hLess - hStep))
printf '%s\n' "${f}: W=${wLess} H=${hLess}"
sed -e "s/W=$w/W=$wLess/" -e "s/H=$h/H=$hLess/" crop.pp3 > "${f}.pp3"
done
printf '%s\n' "All done."
It requires a file crop.pp3 to be present in the same folder, example of such a file:
@Chintan_Gohel, given you want to do a lot of this, I recommend two things:
Get one of the command line image programs, like gmic or Imagemagick
Learn enough scripting in the operating system to run the command line program over your images.
The command line programs offer a more straightforward way to apply edits. Scripting can be daunting, but there’s a particular pattern that is useful, goes like this:
[collect list of images]
foreach image in list:
[do the command line]
done
@Morgan_Hardwood gives the essence of it in bash, here’s the equivalent in Windows cmd shell using gmic and -crop:
echo off
setlocal enabledelayedexpansion
set x0=2
set y0=2
set x1=200
set y1=200
for %%F in (*.jpg) do (
gmic %%F -crop !x0!,!y0,!,!x1!,!y1! -output foo/%%F
set /A x0=x0+2
set /A y0=y1+2
set /A x1=x1-2
set /A y1=y1-2
)
Gah, had to look up about a dozen things to get the above to work, windows cmd shell is a pain. For instance, !x0! says, 'evaluate x0 when you use it, not when the program starts - Really??? Oh, I used variable names consistent with the gmic command reference, and foo/ is a subdirectory under the current directory where the output images go.
A little complicated, but, it does your thing. Save the script; you can put all sorts of gmic (or imagemagick, etc.) things in it…
I am thinking of a different approach to your query. If your goal is to make a time lapse video, it might be simpler to post-process in RT then do the cropping, positioning and/or zooming in the video editor (or an image editor/processor with video capabilities). Or do everything in the latter if you generate a lookup table. If you are unfamiliar with FOSS video editors, I am sure someone in the forum can give you some recommendations.
This was going to be my suggestion as well - or at least to consider something along the lines of what @ggbutcher was suggesting with G’MIC or Imagemagick.
That is - bulk process the images for style, color, etc. Final output at full-sized resolution and further post processing for video output.
I think the biggest reason is that you may not know 100% what you’d like to do with the images in post after processing in RT. You may decide you want to crop but keep the lower left corner the same, as opposed to a push-zoom directly into the center. Processing full-sized images in RT and exporting now allows you to avoid that step the next time around during video editing…
I too think it is best to process the photos in RT and save them uncropped at full resolution, then do the zooming-in in Kdenlive, ShotCut, OpenShot, Blender, Flowblade, Natron or some other non-linear video editor.
I wrote the script because you gave me an excuse to write a script, and to a hammer every problem is a nail.
to all who have replied, thank you - I’ll try using the code as soon as I get a new timelapse sequence where I want to use the code
I have a new issue though: I wanted to know how to combine multiple pairs of images into single images. For example image 1 and 2 into 1 complete image, then with images 3 and 4, 5+6, 7+8 etc
@Chintan_Gohel from this StackOverflow reply, just paste the part from “for” up to “done” into a console. It of course requires that your images are named “1.jpg” … “200.jpg”.
Now a new error which seems obvious to me but I don’t know how to solve it: it can’t find the images which of course it can’t since it doesn’t know where to look for them. So how can I give it the location?
I’ve tried working with that for the last 30 minutes - got nowehere - I’ll look into that further in the morning, it’s 10pm right now and I have to wake up at 5 for work
thank you for your time - hope I have something working tomorrow
I trie this code: montage *.jpg -tile 2x -background white -geometry +2+2 result.jpg
It results in one big file that has all the images in it- and there’s a gap between pairs
If I try with one pair of photos only, the gap is still there between the 2 photos and the new file size is much smaller than the original file. Original files are 450kB each but resulting file is 198kB
Don’t know what to do now - and I have 800 pairs of photo to join
I’m going to post this afresh as it’s own question
Hey, so I finally got to try out your code for the progressive crop.
I’ve run into these errors and I was hoping you could help me out? If it isn’t too much trouble
Thank you
")syntax error: invalid arithmetic operator (error token is "
")syntax error: invalid arithmetic operator (error token is "
./rt.txt: line 17: syntax error near unexpected token $'do\r'' '/rt.txt: line 17: for f in “${files[@]}”;do