konstantin1
28th August 2021, 01:24
I have a quite complex, and memory consuming script, in which I read images, and put them various layers, eg. arrows, text, etc.
I found out, that my script use much less memory, if at a point I write out the layered images to PNG files, and then read them back into variables, and then the following commands, filters use those PNG images in the script.
A sample from my script:
blank=blackness(text,$00000000).trim(0,-1).loop(k0)
image1x1.trim(0,-1).ImageWriter("png\image1x1\", type="png")++k4x4.trim(0,-1).ImageWriter("png\k4x4\", type="png")++text.trim(0,-1).ImageWriter("png\text\", type="png")
image1x1r=imagesource("png/image1x1/000000.png",pixel_type="RGB32",FPS=FPS).trim(0,-1).loop(k0)
k4x4r=imagesource("png/k4x4/000000.png",pixel_type="RGB32",FPS=FPS).trim(0,-1).loop(k0)
textr=imagesource("png/text/000000.png",pixel_type="RGB32",FPS=FPS).trim(0,-1).loop(k0)
stack=output=="gif" ? StackHorizontal(image1x1,k4x4,text,blank) : StackHorizontal(image1x1r,k4x4r,textr,blank)
The problem is that the images are written by ImageWriter only in that case, if ImageWriter is the last command (eg. inserting an __END__ ), and I visit, or let render every 3 frames, and then deleting the __END__ marker.
How can I force imagewriter to write those 3 frames as images?
I found out, that my script use much less memory, if at a point I write out the layered images to PNG files, and then read them back into variables, and then the following commands, filters use those PNG images in the script.
A sample from my script:
blank=blackness(text,$00000000).trim(0,-1).loop(k0)
image1x1.trim(0,-1).ImageWriter("png\image1x1\", type="png")++k4x4.trim(0,-1).ImageWriter("png\k4x4\", type="png")++text.trim(0,-1).ImageWriter("png\text\", type="png")
image1x1r=imagesource("png/image1x1/000000.png",pixel_type="RGB32",FPS=FPS).trim(0,-1).loop(k0)
k4x4r=imagesource("png/k4x4/000000.png",pixel_type="RGB32",FPS=FPS).trim(0,-1).loop(k0)
textr=imagesource("png/text/000000.png",pixel_type="RGB32",FPS=FPS).trim(0,-1).loop(k0)
stack=output=="gif" ? StackHorizontal(image1x1,k4x4,text,blank) : StackHorizontal(image1x1r,k4x4r,textr,blank)
The problem is that the images are written by ImageWriter only in that case, if ImageWriter is the last command (eg. inserting an __END__ ), and I visit, or let render every 3 frames, and then deleting the __END__ marker.
How can I force imagewriter to write those 3 frames as images?