4

I was given code to combine png files to create a gif. I've had it working on another computer using different png files but when I can to use it on another project I get an error that I don't understand (I'm still learning). Can anyone help? The error reads

    imageio.mimsave(output_filename, images, duration=seconds_per_frame)
    Traceback (most recent call last):

      File "<ipython-input-10-3af112267c62>", line 1, in <module>
        imageio.mimsave(output_filename, images, 
    duration=seconds_per_frame)

      File "C:\Users\ashleyp\AppData\Local\Continuum\anaconda3\lib\site- 
   packages\imageio\core\functions.py", line 363, in mimwrite
        raise RuntimeError("Zero images were written.")

    RuntimeError: Zero images were written.

I am in the right working directory and the code seems to work up to the final line. I tried changing the png file names to match the ones the ones I used in the past but this didn't help. I've looked for help on GitHub's Imageio’s user API but found nothing. Program creek has a similar piece of code which from its votes appears to work well but I see no significant differences with mine.

The code I'm using is as follows but I did not write it.

    #set the data directory
    data_dir = r'F:\PhD\Working Files\Surfer\Months\JPEGs\PNGS'

    import glob     # To list files in directory.
    import imageio  # To read and write image files.


    # Configuration parameters.
    output_filename = 'out.gif'
    seconds_per_frame = 0.25


    filenames = sorted(glob.glob('*.png'))
    images = [imageio.imread(filename) for filename in filenames]
    imageio.mimsave(output_filename, images, duration=seconds_per_frame)

I expect the output to be a gif file with 12 frames in it. The error reads

    imageio.mimsave(output_filename, images, duration=seconds_per_frame)
    Traceback (most recent call last):

      File "<ipython-input-10-3af112267c62>", line 1, in <module>
        imageio.mimsave(output_filename, images, 
    duration=seconds_per_frame)

      File "C:\Users\ashleyp\AppData\Local\Continuum\anaconda3\lib\site- 
   packages\imageio\core\functions.py", line 363, in mimwrite
        raise RuntimeError("Zero images were written.")

    RuntimeError: Zero images were written.
Harald K
  • 26,314
  • 7
  • 65
  • 111

0 Answers0