Re: Get center coordinates of object
Posted: 2014-07-12T08:27:58-07:00
What version of IM? What do you get fromThanks a lot for the quick implementation and the information fmw42!
However, I can't get your script to work in my environment. I get to following errors with the original image:
convert -version
What is convert.im6:? My script does not use that syntax!
Send me your email address in a PM on the forum and I will send you a script with some debugging statements and we can see what is going on. It works fine for me on IM 6.8.9.5 Q16 Mac OSX Snow Leopard.
Did you edit the file as described on my home page?
Be sure you have installed the unix calculator, bc. It is an option that you may have to select when installing unix.
Download the script
Change the name to add or remove the .sh as desired when running
Set the script to executable (chmod u+x)
Find the full path to where IM (convert) resides by typing in a shell terminal window: type -a convert
If type -a convert returns more than one path, type in a shell terminal window: path2/convert -version, where path2 is each of the paths found. Decide which version of IM you want to use.
Modify your PATH environment variable so that it includes the full path to where IM (convert) resides (often /usr/bin or /usr/local/bin). This can be done by editing your .profile file.
Alternately, edit the script somewhere between the comments and the first use of any IM command, such as just below the defaults section to add the following two lines:
imdir="path2" #(such as imdir="/usr/local/bin" or imdir="/usr/bin")
PATH="${imdir}:${PATH}"
Open a shell terminal window
bash /fullpathto/scriptname(.sh) arguments /fullpathto/inputimage /fullpathto/outputimage
To avoid the bash and just use scriptname(.sh) ... set your PATH to contain the location of the script
Optionally edit the script to change the default directory (found after the defaults section) from dir="." to dir="/tmp"
If you have trouble with filenames with spaces in them, then you will need to edit the script in several places until I have time to review and fix all my scripts.
Find where infile and outfile (maskfile or any others) are defined at the end of the argument trapping section. Make sure to enclose in double quotes any declarations of those files that include $1, $2, etc, such as infile="$1", etc
Find any occurrences of $infile or $outfile and enclose them in double quotes as "$infile", etc.