8
$\begingroup$

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

$\endgroup$
2
  • 1
    $\begingroup$ In light of Sjore's answer it is interesting why Export["film.avi", ListAnimate[images]] does work? $\endgroup$ Commented May 15, 2012 at 20:42
  • $\begingroup$ 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. $\endgroup$ Commented May 15, 2012 at 22:01

2 Answers 2

9
$\begingroup$

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

$\endgroup$
2
  • 3
    $\begingroup$ It might be worth adding a note that one can use ConformImages to do the conversion in version 10 $\endgroup$ Commented Sep 21, 2014 at 10:12
  • $\begingroup$ A powerful function, indeed. Good find! $\endgroup$ Commented Sep 21, 2014 at 12:35
4
$\begingroup$

I would guess this is because the images are all of different sizes. For a concrete answer about this, contact technical support at [email protected] 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}]] 
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.