8

Here's a list of images:

images = Table[ExampleData[i], {i, ExampleData["TestImage"]}];

And according to the reference "Export exports a list of graphics, images, or arbitrary expressions, taking each element to be an animation frame." This is on the reference page for .avi. However,

Export["animation.avi", images]

causes this:

Export::errelem: "The Export element !(\"ImageList\") contains a malformed data structure and could not be exported to !(\"AVI\") format."

What's the problem?

(Export["film.avi", ListAnimate[images]] works, but I want to know why the above doesn't work...)

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
C. E.
  • 70,533
  • 6
  • 140
  • 264
  • 1
    In light of Sjore's answer it is interesting why Export["film.avi", ListAnimate[images]] does work? – Ajasja May 15 '12 at 20:42
  • Hm... perhaps not. What happens when we export ListAnimate? Basically it's like exporting screenshots of a manipulate-window. All these screenshots have the same size, color channels and so on. – C. E. May 15 '12 at 22:01

2 Answers2

9

The images have different color spaces, dimensions and image channels. How would you make a movie from that?

ImageColorSpace /@ images // Union

(*  ==> {"Grayscale", "RGB"}   *)

ImageDimensions /@ images // Union

(*  ==> {{256, 256}, {512, 512}, {1024, 1024}}  *)

ImageChannels /@ images // Union

(*   ==> {1, 3}  *)

You'd have to convert them all to the same format.

images2 =  ImageResize[ColorConvert[#, "Grayscale"], {256, 256}] & /@ images

will do just that. You can now export it:

Export["animation.avi", images2, "FrameRate" -> 1]

enter image description here

Sjoerd C. de Vries
  • 65,815
  • 14
  • 188
  • 323
4

I would guess this is because the images are all of different sizes. For a concrete answer about this, contact technical support at support@wolfram.com with your license number.

In meantime you can create the animation using a Manipulate:

Export["animation.avi", 
 Manipulate[images[[i]], {i, 1, Length@images, 1}]]
Searke
  • 4,404
  • 20
  • 23