Java: convert set of tiff images to video


I need to write some peace of code that converts set of tiff images to video (avi, mp4 etc). Where can I find the example or could you help me with the issue?



Good day Dima,

first try to achieve what you want via the GUI of ImageJ (the ImageJ user guide may help) and if you are happy with the processing, do the same steps and use the macro recorder with option “Java” to record all the processing steps.




Thank you for the answer. I Converted the images to the video, and opened the recorder. There is the java code that I received:“Image Sequence…”, “open=C:\Users\dima\Desktop\tifs\20171031_204102_A7_F55_FHD_Test13[1]_0000.tif sort use”);, "AVI… ", “compression=JPEG frame=17 save=C:\Users\dima\Desktop\tifs\tifs-17.avi”);

In the second line i got compilation error because imp object wasn’t initialized.
Could you help me with it?



I assume you want a plugin (Java) not a macro, although the latter would do.

In both cases you have to push the button “Create” which gives you the code.

In case of plugins, you have to save the code as file with the class name to the plugins folder of ImageJ and then compile it.

If you are happy with a macro, then you can run the macro code directly after the “Create”.

Please study the ImageJ user guide.




I will try to explain: I have to write some server API that converts tiffs to AVI. I converted the macro to Java and got following code:

ImagePlus imp = IJ.getImage();"Image Sequence...", "open=C:\\Users\\dima\\Desktop\\tifs\\20171031_204102_A7_F55_FHD_Test13[1]_0000.tif sort use");, "AVI... ", "compression=JPEG frame=17 save=C:\\Users\\dima\\Desktop\\tifs\\tifs-17.avi");"Close");"Close");

After import necessary maven artifacts to my project I tried to run following code and got the message:
There are no images open.


Please understand that I can’t debug your code.

If the message says “There are no images open.” then this is just what is happening, i.e. most probable you encountered a path problem.




I found the problem. The macro did some error in code generation. If I swap the line of sequence initialization and “IJ.getImage()” the code works.

Thank you for your time!