Getting started with Fred's Scripts

A plethora of command-line scripts that perform geometric transforms, blurs, sharpens, edging, noise removal, and color manipulations.
PaulAThompson
Posts: 26
Joined: 2012-06-23T10:50:36-07:00
Authentication code: 13

Getting started with Fred's Scripts

Post by PaulAThompson »

I am new to IM but the Fred's scripts seem like a good way to go.

As usual with gnu-ware, the learning curve is steep. I'm an experienced TeX-nician, but am only an amateur at other gnu-tools.

Here's where I am at:

1) Installed cygwin on my Win7 box - I've used this before
2) Downloaded IM 7.6.6 for windows and for cygwin - I'm a little unclear about the use of both of these
3) Downloaded the autolabel script
4) Built a test script
./autolabel -s 100x -p 1 -t "Hey there buddy" armour.jpg farmour.jpg
5) I run the test script
./test
6) I get the bc error

I understand that bc is a *nix utility.

Questions:
1) Specifically how do I install bc in cygwin?
2) How do I modify the scripts to read in all directory locations from a single file, so that I don't need to modify script after script, all over - just one statement to be added - Fred, if you are reading this, you may wish to consider this as an option for the scripts.

I'm certainly willing to keep track of my experience. It's always helpful in starting a gnu-project to have a guide that begins with the ENTIRELY VIRGIN system, and adds the components. With gnu-ware, there is the feeling of being at the start of the little twisty passages from adventure, all alike.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Getting started with Fred's Scripts

Post by Bonzo »

According to the Cygwin Package List bc should already be installed?
PaulAThompson
Posts: 26
Joined: 2012-06-23T10:50:36-07:00
Authentication code: 13

Re: Getting started with Fred's Scripts

Post by PaulAThompson »

The "bc error" that I refer to is

bc: command not found

bonzo: Well, I do
which bc
and get
no bc in (long list of locations)
PaulAThompson
Posts: 26
Joined: 2012-06-23T10:50:36-07:00
Authentication code: 13

Re: Getting started with Fred's Scripts

Post by PaulAThompson »

I went to cygwin and checked the install. It was on the "skip" list. I will install it and retry.
PaulAThompson
Posts: 26
Joined: 2012-06-23T10:50:36-07:00
Authentication code: 13

Re: Getting started with Fred's Scripts

Post by PaulAThompson »

That error is fixed.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Getting started with Fred's Scripts

Post by Bonzo »

Out of interest Paul do you have a php setup on you PC?

A question came up a couple of moths ago about running Fred's scripts through a XAMPP localhost. I tried and it did not work but another user managed to get it working on his PC and they had Cgwin installed. I wondered if the php setup picked up the bc math etc. via the cgwin installation.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Getting started with Fred's Scripts

Post by fmw42 »

PaulAThompson wrote:I am new to IM but the Fred's scripts seem like a good way to go.

As usual with gnu-ware, the learning curve is steep. I'm an experienced TeX-nician, but am only an amateur at other gnu-tools.

Here's where I am at:

1) Installed cygwin on my Win7 box - I've used this before
2) Downloaded IM 7.6.6 for windows and for cygwin - I'm a little unclear about the use of both of these
3) Downloaded the autolabel script
4) Built a test script
./autolabel -s 100x -p 1 -t "Hey there buddy" armour.jpg farmour.jpg
5) I run the test script
./test
6) I get the bc error

I understand that bc is a *nix utility.

Questions:
1) Specifically how do I install bc in cygwin?


2) How do I modify the scripts to read in all directory locations from a single file, so that I don't need to modify script after script, all over - just one statement to be added - Fred, if you are reading this, you may wish to consider this as an option for the scripts.
Unfortunately, I do not use Windows, so cannot answer.

With regard to running them under Cygwin, several people have reported success. There is the possibility of needing to modify the scripts so that IM commands are prefaced with the path to IM inside the scripts as well as perhaps needing to provide the full path to the script depending upon your Cygwin system setup and the directory from where you are calling the script. I have long contemplated modifying my scripts with that built in feature (though not just a single line), but have not had the time to modify 200 scripts. You may also need to provide the full path the images if not in the working directory. Also, you may want to edit the script so that the temporary directory is set from dir="." to dir="/tmp". If any of the above, you can follow the PHP instructions on my web site to do that, though I am not sure all that is necessary for running under Cygwin, if you set up your PATH properly to know where the scripts reside. For more information about using my scripts under Cygwin, refer to http://www.imagemagick.org/Usage/windows/#cygwin

If you discover the proper methods of installing Cygwin and whatever else is needed to get my scripts to run successfully, please post your outline here and I will repost it on my scripts topic in the Announce forum.
PaulAThompson
Posts: 26
Joined: 2012-06-23T10:50:36-07:00
Authentication code: 13

Re: Getting started with Fred's Scripts

Post by PaulAThompson »

Thanks, Fred. I will try to keep notes on my progress. Thus far, I have added a path to the location of the convert file to all the places inside the script. Thus far, I am still not getting joy, but am continuing to work through. I will post to you directly when I do.

I will make the additional fixes suggested by you and the other person, and let you know.
PaulAThompson
Posts: 26
Joined: 2012-06-23T10:50:36-07:00
Authentication code: 13

Re: Getting started with Fred's Scripts

Post by PaulAThompson »

One other thought for you, Fred. Couldn't you write a simple Perl script which would do the conversion? I will do that, and send it to you.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Getting started with Fred's Scripts

Post by fmw42 »

PaulAThompson wrote:Thanks, Fred. I will try to keep notes on my progress. Thus far, I have added a path to the location of the convert file to all the places inside the script. Thus far, I am still not getting joy, but am continuing to work through. I will post to you directly when I do.

I will make the additional fixes suggested by you and the other person, and let you know.
If you read my notes regarding using the script on Mac/Linux or under PHP on my web site, you will see that there is a quick way to put a few lines of code in the script to put the path to IM in front of every IM command, including convert, identify, etc. You may have overlooked other IM commands besides convert. Also the other items listed there may also be helpful to you. So please read those sections.


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}"

This was a helpful tip from Anthony.



Sorry I do not use or know Perl.


Let me make a suggestion. Create a simple one line bash shell script to process an image with one simple convert command. Try to get that working first before trying to get my scripts to work. That way, you can find out what simple changes are needed to the script.

In fact, even before that, try pasting or typing one simple IM convert command into your Cygwin terminal and see if it process the command successfully or what changes such as paths are needed to make it work. Perhaps Cygwin/IM is not properly installed. This would be a simple first test. The move on to the above simple test script. Once those both work, then try my scripts with whatever changes you have found were needed by the first two tests.

try testing with:

convert image -rotate 90 result
PaulAThompson
Posts: 26
Joined: 2012-06-23T10:50:36-07:00
Authentication code: 13

Re: Getting started with Fred's Scripts

Post by PaulAThompson »

I did the simple one-line script approach, except it had 4 lines

imdir="/cygdrive/c/Program Files/ImageMagick-6.7.7-Q16"#
#(such as imdir="/usr/local/bin" or imdir="/usr/bin")
PATH="${imdir}:${PATH}"#
#
convert armour.jpg -rotate 90 nresult.jpg

This worked fine, and created a rotated image in nresult.jpg which was taken from armour.jpg

My call to autolabel is
./autolabel -s 100 -t "Hey there buddy" armour.jpg farmour.jpg

convert.exe: unable to open image '/tmp/autolabel_1_6455.mpc': no such file or directory @ error/blob.c/OpenBlob/2617

--- FILE armour.jpg DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---

I am not clear what the problem is.
PaulAThompson
Posts: 26
Joined: 2012-06-23T10:50:36-07:00
Authentication code: 13

Re: Getting started with Fred's Scripts

Post by PaulAThompson »

OK, success!

I replaced
dir="/tmp"
with
dir="."

and got my file with the text written.

I continue to get an error message, however. I am trying to use the -m caption option, but this produces an error message:
:integer expression expected
--- Invalid Combination of Pointsize and Size ---

The call is
./autolabel -s 100 -m caption -t "Hey there buddy" armour.jpg farmourc.jpg

Changing it to
./autolabel -s 100x10 -m caption -t "Hey there buddy" armour.jpg farmourc.jpg
worked, but the location of the text did not change.

Is there a script which will put the text in a specific place?
PaulAThompson
Posts: 26
Joined: 2012-06-23T10:50:36-07:00
Authentication code: 13

Re: Getting started with Fred's Scripts

Post by PaulAThompson »

I continue to get the
integer expression expected
message, but the script does produce an output.

By changing to
-size 40x20 -m caption
I get a different result, the text is now in two rows.

Here is my objective:
1) Take a number of photos
2) Add a caption and possibly a frame (picframe may do this)
3) Add text to the bottom border (autolabel and other tools don't seem to give control of location - is there a script which allows the user to define the location?)
4) Save result

If possible, I would like to put all of this into a file with optional separator, and then gang-process a number of photos in this way. I could write a perl script which would do this. Any other approach?
PaulAThompson
Posts: 26
Joined: 2012-06-23T10:50:36-07:00
Authentication code: 13

Re: Getting started with Fred's Scripts

Post by PaulAThompson »

Fred:

I hacked the autolabel script to optionally position the text at a point of the user's desire. If you were interested, I could send you my modified script.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Getting started with Fred's Scripts

Post by Bonzo »

I hacked the autolabel script to optionally position the text at a point of the user's desire.
If you are going to do that why not just use annotate or draw; one line of code?
1) Take a number of photos
2) Add a caption and possibly a frame (picframe may do this)
3) Add text to the bottom border (autolabel and other tools don't seem to give control of location - is there a script which allows the user to define the location?)
4) Save result
This could also be done in two or three of lines of code; I think you should investigate IM useage more.

All without the use of Cgwin as well; you could use batch scripts if you wanted to.
Post Reply