Log in

View Full Version : Can you call ImageWriter twice in one script?


rookandpawn
1st May 2009, 06:56
(edited to improve readibility)

image1 = ImageSource("foo.png").Trim(0,-1)
image2 = ImageSource("bar.jpg").Trim(0,-1)
ImageWriter(image1,"D:\cat",0,0,"png")
ImageWriter(image2, "D:\dog", 0,0, "png")

The first call to ImageWriter never hits the disk to write it out...
Only the second. How can i achieve multiple calls to ImageWriter?

I think i may be misunderstanding the script execution model.. or something about ImageWriter... Basically I want to be able to call ImageWriter twice in the same script, each on separate files that are of different sizes.. But there is something that isnt letting ImageWriter "run twice"?

IanB
1st May 2009, 07:09
If I add the implicit Last syntax processing to your script can you see the problemimage1 = ImageSource("foo.png")
output = image1.Trim(0,-1)
Last=ImageWriter(output,"D:\bar",0,0,"png",info=true)
image2 = ImageSource("foo.jpg")
output2 = image2.Trim(0,-1)
Last=ImageWriter(output2, "D:\baz", 0,0, "png")
Return Last

rookandpawn
1st May 2009, 07:32
I still dont see the problem. I just know that ImageWriter is only writing one file. If I comment out the last ImageWriter call, the first ImageWriter file is written.
I also thought that ImageWriter doesnt care about implicit last if I supply the clip variable (in this case, output and output2)

Gavino
1st May 2009, 10:12
The problem is that ImageWriter only writes out frames that are rendered in the final result of the script - that's just the way Avisynth works. Since the result of the first ImageWriter call is not used, it never gets a chance to write anything to the file.

You need to do something like this:
a = ImageWriter(...)
b = ImageWriter(...)
return a + b

(and, of course, 'play' the entire output clip).