Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Gimp-Python way to create square-selection Marquee, that user sizes and places?
#3
Been there, done (nearly) that. The result is in my ofn-file-next script that you can adapt to your needs. It is used like this:

  1. You "manually" open the first image in a series
  2. You do whatever manual processing is required (for me, that was rotate/crop, for you that could be marking a selection or doing the crop)
  3. You hit a key to call the script (you added a shortcut for the script beforehand)
  4. The script finishes the processing (or me nothing to do, for you possibly crop and scale), saves the image, and opens the next in sequence
  5. You are back to #2, with the next image loaded.
So in this workflow, you call a script once per image. This is quite efficient, I handled a couple hundred images in 20 minutes once.

The difference with your requirements:

  1. You can make a selection or a crop. In both cases, you can preset the tool for 1:1 aspect ratio. Doing the crop doesn't take longer (just one keystroke)
  2. I don't scale in the script (in my processing, I did scale, but this was done later in batch using ImageMagick in a shell script). Not hard to add. But if you use the crop in the first step you can use my script directly if you scale in batch.
  3. My script saves the image back to the source file. But you can copy all your files to a squared directory first.
My IM script was like this:

Code:
#! /bin/bash

dir=${1:-.}

for f in "$dir/"*.JPG;  
do
       echo "Processing $f"
       convert "$f" -resize 600x -sharpen 0x1.0 -quality 85 "$dir/$(basename "$f" .JPG).jpg"
done

(it resizes to 600px wide, and does a slight sharpening to mitigate the blur due to the resize). I since found a way to write the script without looping on the files (easier if you are on Windows). You can also use mogrify instead of convert to resize the files directly without making a new copy.
Reply


Messages In This Thread
RE: Gimp-Python way to create square-selection Marquee, that user sizes and places? - by Ofnuts - 10-18-2022, 10:41 PM

Forum Jump: