View previous topic :: View next topic |
Author |
Message |
Ephemeral Advanced Member
Joined: 26 Jun 2025 Posts: 671 Location: UK
|
|
Back to top |
|
VHockey86 Advanced Member

Joined: 12 Dec 2025 Posts: 988 Location: Rochester
|
Posted: Tue Sep 02, 2025 2:11 pm Post subject: |
|
|
should be able to take care of that with imagemagick and cropping easily enough.
http://www.imagemagick.org/Usage/crop/
Bash or python or whatever for the scripting part of it.
You can also do gimp scripts, or there's even a plugin for scripting gimp with python, but that is probably overkill and would take too long to figure out for something as simple as you're doing.
http://www.gimp.org/docs/python/pygimp.html
|
|
Back to top |
|
Ephemeral Advanced Member
Joined: 26 Jun 2025 Posts: 671 Location: UK
|
|
Back to top |
|
crouse Site Admin

Joined: 17 Apr 2025 Posts: 11833 Location: Iowa
|
Posted: Tue Sep 02, 2025 3:48 pm Post subject: |
|
|
You could modify some of my bbips scripts to do that....
here is the url for the "crop" section dealing with imagemagick
http://www.imagemagick.org/Usage/crop/#crop
Here is a quick bash script I put together...... didn't test it, but it should do the trick i think.... you will need to modify the settings to suit your needs.
Code: |
#!/bin/bash
# by Crouse 09-02-2008
# Save and run file in directory of images to be changed.
# Crops .png files to size and then changes them to .eps files.
# Check for required programs
if [[ -z $( type -p convert ) ]]; then echo -e "ImageMagick -- NOT INSTALLED !";exit ;fi
if [[ -z $( type -p sed ) ]]; then echo -e "sed -- NOT INSTALLED !";exit ;fi
# Set IFS to correct parameter
export IFS=$'\n';
# Use Imagemagick to crop images
for i in $(find . -maxdepth 1 -type f -iname "*.png");
# Change 32x32 to reflect size of image wanted, and 0+0 is offset if needed.
do
convert ${i} -gravity Center -crop 32x32+0+0 +repage ${i}
done
# Change extentions from .png to .eps
echo "Converting from .png to .eps"
match=".png";
replacewith=".eps";
for i in $( find -iname ".png" );
do
src=$i
tgt=$(echo $i | sed -e "s/$match/$replacewith/")
echo renaming $src to $tgt
mv $src $tgt
done
|
_________________ Veronica - Arch Linux 64-bit -- Kernel 2.6.33.4-1
Archie/Jughead - Arch Linux 32-bit -- Kernel 2.6.33.4-1
Betty/Reggie - Arch Linux (VBox) 32-bit -- Kernel 2.6.33.4-1
BumbleBee - OpenSolaris-SunOS 5.11
Last edited by crouse on Wed Sep 03, 2025 7:51 pm; edited 1 time in total |
|
Back to top |
|
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 607 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Tue Sep 02, 2025 4:44 pm Post subject: |
|
|
crouse wrote: | ...
Code: |
#!/bin/bash
# by Crouse 09-02-2008
# Save and run file in directory of images to be changed.
# Crops .png files to size and then changes them to .eps files.
# Check for required programs
if [[ -z $( type -p convert ) ]]; then echo -e "ImageMagick -- NOT INSTALLED !";exit ;fi
# Set IFS to correct parameter
export IFS=$'\n';
# Use Imagemagick to crop images
for i in $(find . -maxdepth 1 -type f -iname "*.png");
# Change 32x32 to reflect size of image wanted, and 0+0 is offset if needed.
do
convert ${i}: -gravity Center -crop 32x32+0+0 +repage $(dirname ${i})/$(basename ${i} .png).eps
done
|
|
same but converts the filename at the same time, also saves the original just in case the settings are wrong. (also doesn't depend on sed anymore only coreutils which is a dependency of imagemagick.)
_________________ ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)
PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
|
|
Back to top |
|
Ephemeral Advanced Member
Joined: 26 Jun 2025 Posts: 671 Location: UK
|
Posted: Wed Sep 03, 2025 2:28 pm Post subject: |
|
|
Quote: | dirname ${i}
basename ${i} .png
convert: unable to open image `./Lsys4.png:': No such file or directory.
convert: missing an image filename `./Lsys4.eps'.
dirname ${i}
basename ${i} .png
convert: unable to open image `./Lsys6.png:': No such file or directory.
convert: missing an image filename `./Lsys6.eps'.
dirname ${i}
basename ${i} .png
convert: unable to open image `./Lsys5.png:': No such file or directory.
convert: missing an image filename `./Lsys5.eps'.
dirname ${i}
basename ${i} .png
convert: unable to open image `./Lsys3.png:': No such file or directory.
convert: missing an image filename `./Lsys3.eps'.
dirname ${i}
basename ${i} .png
convert: unable to open image `./Lsys7.png:': No such file or directory.
convert: missing an image filename `./Lsys7.eps'.
dirname ${i}
basename ${i} .png
convert: unable to open image `./Lsys8.png:': No such file or directory.
convert: missing an image filename `./Lsys8.eps'.
dirname ${i}
basename ${i} .png
convert: unable to open image `./Lsys1.png:': No such file or directory.
convert: missing an image filename `./Lsys1.eps'.
dirname ${i}
basename ${i} .png
convert: unable to open image `./Lsys.png:': No such file or directory.
convert: missing an image filename `./Lsys.eps'.
dirname ${i}
basename ${i} .png
convert: unable to open image `./Lsys2.png:': No such file or directory.
convert: missing an image filename `./Lsys2.eps'. |
im getting this message from the terminal
cant see whats wrong atm
|
|
Back to top |
|
rumbarg Jr. Member
Joined: 06 Jun 2025 Posts: 69 Location: Houston, TX
|
Posted: Wed Sep 03, 2025 5:50 pm Post subject: |
|
|
Try removing the colon after the ${i} in this line
Code: | convert ${i}: -gravity Center -crop 32x32+0+0 +repage $(dirname ${i})/$(basename ${i} .png).eps |
so that it's Code: | convert ${i} -gravity Center -crop 32x32+0+0 +repage $(dirname ${i})/$(basename ${i} .png).eps |
I think it snuck in - at least that got rid of the problem here.
regards,
rumbarg
_________________ sidux sidux 2025-01 - Χάος
|
|
Back to top |
|
crouse Site Admin

Joined: 17 Apr 2025 Posts: 11833 Location: Iowa
|
|
Back to top |
|
Ephemeral Advanced Member
Joined: 26 Jun 2025 Posts: 671 Location: UK
|
|
Back to top |
|
rumbarg Jr. Member
Joined: 06 Jun 2025 Posts: 69 Location: Houston, TX
|
|
Back to top |
|
|