This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

how can I launching external programs?

24 posts · 9971 views

Hi,

First of all, I want to point out, that I am not a native englisch speaker. Please don't worry about my englisch. I am currently try to improve it.
I am now writing my bachleor thesis in computer sciences at the university of applied schiences of Trier/Germany. I am programming with Lisp on
Lispworks personnal edition 5.0.0.1. I recentliy have a big problem, so that it is no more possible continiuing work on the project. That's the reason
of my post here. I'll be very happy if somebody can help me solve the problem.

My problem:

I want to convert a lot of text-files (stored in a directory) into jpg-image-files. I recently discover that when opening a txt-file with the
IrfanView-programm, this is show like an image, so that the only thing I had to do, was to stored it with the extension .jpg.
So I want to write a lisp-code (one or many function(s)/...), that make this automaticaly: That mean ivoke a thing that can automaticaly launch the IrfanView-programm, read an stored file from it.

1. Open the directory
2. for each file:
2.1. open this file with IrfanView
2.2. stored it as an .jpg image

can anybody tell me how can I do that? or perhaps give me some usefull informations?

Thanks a lot for your answer

Re: how can I launching external programs?

@Ramarren
Hello. I think ImageMagik is not a free software. I want to use IrfanView.
However I know how tu open the file with (sys:call-system '("i_view" "myFile.txt")), I hoppe it's correct.
But I don't know how to store it as jpg-image!!

Please have you got au code for me? or another helpful link?

Thanks for answer

Re: how can I launching external programs?

Wolfgang Tsafack wrote:Hello. I think ImageMagik is not a free software. I want to use IrfanView.
Um, what?
ImageMagick is free software delivered as a ready-to-run binary distribution or as source code that you may freely use, copy, modify, and distribute. Its license is compatible with the GPL. It runs on all major operating systems.
It is right there on the home page.

For that matter:
IrfanView is a very fast, small, compact and innovative FREEWARE (for non-commercial use) graphic viewer for Windows 9x, ME, NT, 2000, XP, 2003 , 2008, Vista, Windows 7.
So it's exactly the other way around.

Re: how can I launching external programs?

Thank you very much Rammaren,

I think I will use ImageMagick! I didn't know that. This software is not very used by us.

But what about the question to save it as jpg-image? after call call-system function?
I don't have any idea?

Thanks

Re: how can I launching external programs?

Wolfgang Tsafack wrote:But what about the question to save it as jpg-image? after call call-system function?
I don't have any idea?
As far as I can tell IrfanView is not designed to be externally scriptable, therefore it is not possible to do this with a programming language. That is why I recommended a command line utility, which can be just called with
(system:call-system "convert txt:example-text-file example-text-file.jpg")
Do note that using jpg format for text rasterization is not a good idea due to compression artefacts. A png or even gif would be much better.

Re: how can I launching external programs?

@Remarren

thanks a lot for your help. That is right with the jpg option! But for my work it is not more important. However I'll make it wiht gif extension.

I'll want to clear somme point in the calling of
(system:call-system "convert txt:example-text-file example-text-file.jpg"):

1. I suppose that the files have to be given with their hole Pfad: for example "C:/dir/subdir/file.txt"
2. txt:example-text-file means that the file is a txt file, how it's if my text-file allready have an .txt extension? Do I allways need to add text: before that file?
3. Must example-text-file.jpg have the same pathname like the first txt to be store in the same directory?

I know I ask a lot, but I need this informations.

thanks al lot again!!!

Re: how can I launching external programs?

Wolfgang Tsafack wrote:@Ramarren
Hello. I think ImageMagik is not a free software. I want to use IrfanView.
I think you are using the term "free" as in "free beer", because IrfanView (nor Lispworks) is not free (as in freedom) software.

Just to note, you are probably not allowed to sell or even distribute software compiled with Lispworks (someone correct me if I am wrong about "distribute"), though you can always distribute the source code and tell people to compile it themselves.

Re: how can I launching external programs?

@Ramarren

When try tu run this peace of code on Lispworks 5.0.1, I saw the shell fastly showing wiht a lot of thinks inside. But I didn't any image file on my computer.
I search the file Belege-txt/20060629-10-14-56.jpg, but not one. Where did the file was stored? I don't have any idea.
That was what I want to do, have the image file stored in the same directory wiht the text file.
(sys:call-system "convert txt:D:/LispWorks/AA/Belege-txt/Belege-txt/20060629-10-14-56.txt
                  D:/LispWorks/AA/Belege-txt/Belege-txt/20060629-10-14-56.jpg")

Re: how can I launching external programs?

gugamilare wrote:Just to note, you are probably not allowed to sell or even distribute software compiled with Lispworks (someone correct me if I am wrong about "distribute"), though you can always distribute the source code and tell people to compile it themselves.
You're wrong. A Lispworks application or library built with the delivery runtime can be distributed with no additional runtime licensing.

http://www.lispworks.com/products/runtimes.html

Maybe you're thinking of Franz' Allegro CL ?

-a

Re: how can I launching external programs?

Wolfgang Tsafack wrote:When try tu run this peace of code on Lispworks 5.0.1, I saw the shell fastly showing wiht a lot of thinks inside. But I didn't any image file on my computer.
Program convert shouldn't print anything in normal circumstances. Depending on how it was installed, you might need to specify full path to the program as well. Also, is the path separator on Windows not backslashes? In any case, the terminal output from the convert program is most likely describing the error.

Re: how can I launching external programs?

sinnatagg wrote:
gugamilare wrote:Just to note, you are probably not allowed to sell or even distribute software compiled with Lispworks (someone correct me if I am wrong about "distribute"), though you can always distribute the source code and tell people to compile it themselves.
You're wrong. A Lispworks application or library built with the delivery runtime can be distributed with no additional runtime licensing.

http://www.lispworks.com/products/runtimes.html

Maybe you're thinking of Franz' Allegro CL ?

-a
In that page you cited:
[...]LispWorks Personal Edition does not include delivery.[...]
So, unless you pay for a license, you cannot "deliver". I am still not sure if there is another way of creating an executable which is allowed to be distributed, or if you can distribute compiled files.

Re: how can I launching external programs?

@Ramerren

Are you seen this post. Please help solve this problem:

____________________________________________________________
Re: how can I launching external programs?

Postby Wolfgang Tsafack ยป Sat Nov 07, 2009 12:18 pm
@Ramarren

When try tu run this peace of code on Lispworks 5.0.1, I saw the shell fastly showing wiht a lot of thinks inside. But I didn't any image file on my computer.
I search the file Belege-txt/20060629-10-14-56.jpg, but not one. Where did the file was stored? I don't have any idea.
That was what I want to do, have the image file stored in the same directory wiht the text file.
(sys:call-system "convert txt:D:/LispWorks/AA/Belege-txt/Belege-txt/20060629-10-14-56.txt
D:/LispWorks/AA/Belege-txt/Belege-txt/20060629-10-14-56.jpg")

Re: how can I launching external programs?

Wolfgang Tsafack wrote:@Ramerren

Are you seen this post. Please help solve this problem:
I already did.

Re: how can I launching external programs?

@Ramarren

I got it. I wokr!
But there is a problem: When converting a long file, ImageMagick make two image files.
For example I try to convert file123.txt, imageMagick make the 2 files file123-0.jpg and file123-1.jpg.
How can I make sure that, it convert the given file into only one file123.jpg

Thanks

Re: how can I launching external programs?

I enjoy to early.

whe work on command line editor for windows, i discover that it was not necessary to enter on the imageMagick directory to convert the file:
ImageMagick ist installed on my system at: C:\Program Files\ImageMagick-6.5.7-Q16. But I use my editor at: C:\User\Willy> an then I typed:
convert D:\Lispworks\AA\Belege-ocr\20060623-11-48.txt D:\Lispworks\AA\Belege-ocr\20060623-11-48.jpg I got the 2 files
20060623-11-48-0.jpg and 20060623-11-48-1.jpg created in the directory D:\Lispworks\AA\Belege-ocr\. that was in the DOS-console [the command line editor]

But when try to run the following code on Lispworks:
(sys:call-system "convert D:\LispWorks\AA\Belege-ocr\20060623-11-48-23Kopie.txt
                  D:\LispWorks\AA\Belege-ocr\20060623-11-48-23Kopie.jpg")
. it didn't work. Why?
Therefore I tried to give the full path of the convert program wiht:
(sys:call-system "C:\Program Files\ImageMagick-6.5.7-Q16\convert.exe D:\LispWorks\AA\Belege-ocr\20060623-11-48-23Kopie.txt
                  D:\LispWorks\AA\Belege-ocr\20060623-11-48-23Kopie.jpg")
. It didn't work too.
Then I tried to remove .exe on the programm path wiht:
(sys:call-system "C:\Program Files\ImageMagick-6.5.7-Q16\convert.exe D:\LispWorks\AA\Belege-ocr\20060623-11-48-23Kopie.txt
                  D:\LispWorks\AA\Belege-ocr\20060623-11-48-23Kopie.jpg")
.It didn't work

Why does the code don't work? I don't have any idea ?
I will try on the imagemagick forum to get more information

Re: how can I launching external programs?

Wolfgang Tsafack wrote:How can I make sure that, it convert the given file into only one file123.jpg
As far as I can tell, it is not possible. At best, you can generate only the first page and discard the rest, see text operations Imagemagick usage examples. The other option would be to generate all the subimages, gather them from lisp with DIRECTORY and them combine them into one using the montage command.

Re: how can I launching external programs?

@Ramarren,
As far as I can tell, it is not possible. At...
I got it in only one image with adding the command line option append like this:

typing this
convert D:/LispWorks/AA/Belege-ocr/20060623-11-48-23Kopie.txt [b]+append[/b] D:/LispWorks/AA/Belege-ocr/20060623-11-48-23Kopie.jpg
on the DOS comand line editor, i obtain only one file 20060623-11-48-23Kopie.jpg

Now why did the same don't work in a lisp code?

I wrote:
(sys:call-system "convert D:/LispWorks/AA/Belege-ocr/20060623-11-48-23Kopie.txt +append D:/LispWorks/AA/Belege-ocr/20060623-11-48-23Kopie.jpg")
on lispworks. but it didn't work (the same work on Dos comand line editor!) what is the problem. What is the mistake a did??

@Anybody:

Can anybody take part in the topic? Please help me solve this problem. I fill it, i will get it soon. I just need a little thing i don't know.
Help please.

Re: how can I launching external programs?

I don't have an answer for you, but I'd simply note that at this point you're asking ImageMagick support questions, not Lisp support questions. You might be better served by finding an ImageMagick forum or resource and asking there.
Cheers, Dave
Slowly but surely the world is finding Lisp. http://www.findinglisp.com/blog/

Re: how can I launching external programs?

I don't know the exact lispworks syntax; but I suspect your problem is that the program name ("convert") is not separate from the arguments ("D:/...Kopie.txt", "+append", and "D:/...Kopie.jpg"). Text entered at a shell prompt is split at whitespace boundaries. This same splitting does not happen in lisp strings.

Re: how can I launching external programs?

Here's another way to do it, create an svg image using something like this saved to an x.svg file, with the 'Hello out there' words replaced:
(setf ss "<?xml version=\"1.0\" standalone=\"no\"?>
<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" 
  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">
<svg width=\"10cm\" height=\"3cm\" viewBox=\"0 0 1000 300\"
     xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">
  <desc>Example text01 - \"Hello out there\" in blue</desc>
  <text x=\"250\" y=\"150\" 
        font-family=\"Verdana\" font-size=\"55\" fill=\"blue\" >
    Hello out there
  </text>
  <!-- Show outline of canvas using rect element -->
  <rect x=\"1\" y=\"1\" width=\"998\" height=\"298\"
        fill=\"none\" stroke=\"blue\" stroke-width=\"2\" />
</svg>")

Re: how can I launching external programs?

@methusala

I really don't understand what you mean. You decsrible an xml-script. How can i put my Text inside the svg-image?

@others

1. That' perhaps the better thing to do: visiting an Imagemagick-forum. I will do it, but let talk about the problem again

2. I got it with this code last weekend:
(system:call-system '("C:/Program Files/ImageMagick-6.5.7-Q16/convert"
                                         "D:/LispWorks/AA/Belege-ocr/20060623-11-48-23.txt"
                                         "+append"
                                         "D:/LispWorks/AA/Belege-ocr/20060623-11-48-23.jpg"))
I became an image created on the specify directory. with add "+append" beetwen the to files-pathes, i make sure that i become only one image.

So now to anther problem. When try to run the same peace of code like this:
(defun test()
(setf txt "D:/LispWorks/AA/Belege-ocr/20060623-11-48-23.txt")
(setf jpg "D:/LispWorks/AA/Belege-ocr/20060623-11-48-23.jpg")
(system:call-system '("C:/Program Files/ImageMagick-6.5.7-Q16/convert"
                      txt
                      "+append"
                      jpg)))
It didn't work!!! I later want to create image files belong to many text files. That mean I will have this patch stored in a variable. that the reason I make a probe to check out if the code work! Why didn't it work??. I became the following error:
Each element of COMMAND must be of type STRING : (C:/Program
Files/ImageMagick-6.5.7-Q16/convert TXT +append JPG)
. Please note that the first code (editing at the top of this post worked!). Why didn't the second code work?

thank you for all help

Re: how can I launching external programs?

Wolfgang Tsafack wrote:Why didn't the second code work?
This is elementary Common Lisp. In:
'("C:/Program Files/ImageMagick-6.5.7-Q16/convert"
  txt
  "+append"
  jpg)
you create a list with two strings and two symbols. You want to create a list with four string, two of which are values of variables:
(list "C:/Program Files/ImageMagick-6.5.7-Q16/convert"
      txt
      "+append"
      jpg)
The character #\' is syntax for QUOTE, which does not evaluate its arguments.

EDIT: Also, using SETF this way is wrong. Use LET to establish local variable binding. I suggest that you read a text on Common Lisp written in this millenium, like PCL. Unfortunately, I know not of any comparable text in German.