Open and save .jpg files repetitively and visualize in real time

Hi to everyone.

I am a newbie to the forum [and a beginner of Touch], so I apologize in advance, if I have wrong some procedure.

I would like to know if there is any possibility of doing the following with Touchdesigner:
is it possible to open and save an image file [in particular a .jpg file] countless times [editable parameter], displaying the result in real time as an output by an operator in touchdesigner?

Years ago a friend of mine built a patch in Processing, capable of doing this. Since Touchdesigner is also based on python, I was wondering if it was possible to create such a thing with the latter.

Thanks everyone in advance!

I donā€™t see why not. moviefileinTOP and moviefileoutTOP are the operators you want.

1 Like

Given the potential of a touch designer, I imagined he might be able to do it. However, being a beginner I donā€™t know how to do this work. Soā€¦ is it possible to have more precise information on how to proceed?

take a look at the python docs for TOPs. Hereā€™s the docs for a null TOP, but the generic functions n stuff apply to all tops.

Jump to the section about:
save(filepath, asynchronous=False, createFolders=False)

The bare minimum to achieve what youā€™re looking for would look like this:
op('PathToSomeTOP').save('AbsoluteOrRelativeFilePathToSave.jpg')

1 Like

Thanks for your advice. I will try to put them into practice and let you know.

1 Like

Note: In 40k, the Script TOP now has methods to save/load directly from a bytearray, avoiding the need for disk access:

	f = op('moviefilein1')			
	b = f.saveByteArray('.jpg', quality = 0.1)
	scriptOp.loadByteArray('.jpg', b)

Cheers

3 Likes

Hi Rob. I downloaded the 2020.42700 version of td. Iā€™ve located the TOP Script. I imagine that the script that you suggested to me should be written in the Text DAT of the operator in question. I tried to understand how and where, but with poor results [do I have to insert the new script after the ones already existing in the Text Dat, or do I have to delete everything and write only the new one? Forgive me if I use inappropriate terms ā€¦]. Could you advise me how [forgive me, but my knowledge of python is almost zero]? Also, does the fact that the ā€œfā€ attribute corresponds to the ā€œmoviefilein1ā€ operator mean that a Movie File In TOP operator must be present in the td project?

Thanks in advance

Iā€™ve attached a small example.
You can set the quality and the extension (Though I believe only ā€˜.jpgā€™ uses a quality value).
Unfortunately youā€™ll see it reaches a steady-state quite quickly.

I thought this was a bug, until I read itā€™s a characteristic of the encryption algorithm:

Enjoy.
Rob.
jpeg_test.10.toe (4.0 KB)

1 Like