Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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...)

share|improve this question
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. –  Pickett May 15 '12 at 22:01

2 Answers 2

up vote 7 down vote accepted

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

share|improve this answer
1  
It might be worth adding a note that one can use ConformImages to do the conversion in version 10 –  Simon Woods 20 hours ago
    
A powerful function, indeed. Good find! –  Sjoerd C. de Vries 17 hours ago

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}]]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.