Page 1 of 1

using an internal path in a command

Posted: 2019-08-14T12:09:38-07:00
by davemagi
To anyone who can help !

Observe the following command;

magick -font Courier-New -page 940x600 TEXT:fxDTable.txt +repage fxDTable.jpg

It works perfectly for what I need it to do (i.e. convert a text file to a jpeg)

So whats the problem ? The path to the file in the next command is the problem.

"C:\Program Files\ImageMagick-7.0.8-Q16\magick -font Courier-New -page 940x600 TEXT:c:\temp\fxrpts\fxDTable.txt +repage fxDTable.jpg

There are several issues here;

1) the path to the magick executable seems to work fine, things get sticky when I put a path after the 'TEXT:' part of the command (i.e. c:\temp\fxrpts...). I get a 'cannot find file' message.

2) Besides the above there may be a problem with parsing the break in such a long command line. How is this usually handled ?

3) I have seen in the documentation a parameter called 'MAGICK_TEMPORARY_PATH'. Would this be necessary or even helpful to my cause ?

4) I would really like to have a pdf file instead of a jpeg, but I have not been able to get this to work. Would you know the change I have to make to get a pdf as the output file ?

If it helps, I am using this command under AutoHotKey to automate a process. Their documentation states that a line break can be handled with an 'and' or ',' or '&&' but imagemagick may not like this.

Thank You for any help you can provide

Re: using an internal path in a command

Posted: 2019-08-14T12:22:23-07:00
by snibgo
1. The IM code that parses filename isn't perfect. In particular, is gets confused by drives like "C:". I suggest you arrange it so the drive is not needed. Don't use %TEMP% because that probably contains a disk drive.

2. In Windows, a caret ^ at the end of a line means the command is continued on the next line. See my pages for many Windows "BAT" examples.

3. The temporary path is used internally by IM to store temporary files. You can set that to be something else if you want, but I don't think that would directly help you.

4. Change the output extension from "jpg" to "pdf".

I know nothing about AutoHotKey, but caret end-lines and && and so on are handled by the shell, and are not passed on to IM.

Re: using an internal path in a command

Posted: 2019-08-15T07:16:19-07:00
by davemagi
Thanks for the help. I am sorry to hear that drives and paths are such a mystery in IM. I was hoping that I was not the first to deal with this issue, but I couldn't find any reference to it in the archives.

Re: using an internal path in a command

Posted: 2019-08-15T08:54:22-07:00
by snibgo
You are not the first, sadly, and I doubt you will be the last.

But do check that my guess is correct. If you remove "C:", does that cure the problem?