Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Batch edit photos, shave off 20 pixels off the top
#1
I have hundreds of png files that need the top 20 pixels shaved off. Is there a way to do this by batch? I’m reasonably good at terminal or I have graphic converter. Thanks.
Reply
#2
Try ChatGPT to write a simple Python code.
Reply
#3
I ended up using the command
mogrify -crop 1280x1024+0+0 *.png
which I found at https://superuser.com/questions/1161340/...mmand-line .

Then I wrote a simple script to do the job for me as it is a reoccurring situation.

#!/bin/bash
while true; do
echo
This will modify the files. Hope you have a backup!
read -p
Are you in directory with image files?
yn
case $yn in
[Yy]* ) echo
;
read -p
What extension do the image files have?
extention
identify *.
$extention
echo
**Now you know the resolution of the files in dir

echo
Now set the width and length
echo
For Architectural Digest use 2064 and 2602
echo
read -p
What width from left border is desired?
width
read -p
What length is desired?
length
echo
echo
Now set the offsets
echo
For Architectural Digest use 0 and 150
echo
read -p
What offset from left is desired?
xoffset
read -p
What offset from top is desired?
yoffset
echo
echo
Modifying original files, hope you made a backup...
mogrify -verbose -crop
$width
x
$length
+
$xoffset
+
$yoffset
*.
$extention
break;;
[Nn]* ) echo
Please place files into folder and run again.
; exit;;
* ) echo
Please answer yes or no.
;;
esac
done

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)