I have two gif files and I want to import and play them at the same time with just one play button. The target is to compare them easily. Is there any way?


It's actually quite an ugly code, but it should do the job:

twogifs[X_, Y_] := (
  a = Import[X];
    b = Import[Y];
  ai = ImageDimensions[a[[1]]];
  b1 = ConstantArray[0, Length[b]];
  For[i = 1, i < Length[b] + 1, i++, 
   b1[[i]] = ImageResize[b[[i]], ai]];
  If[Length@a < Length@b1, 
   AppendTo[a, ConstantArray[a[[-1]], Length@b1 - Length@a]];
   a = Flatten@a, 
   If[Length@a > Length@b1, 
    AppendTo[b1, ConstantArray[b1[[-1]], Length@a - Length@b1]]];
   b1 = Flatten@b1];

  allImg = ImageAssemble[{#[[1]], #[[2]]}] & /@ Transpose[{a, b1}];



The function is edited and first resizes the gifs to be equal-sized and then makes them equal in number.

  • $\begingroup$ Don't worry about the ugliness. It works and that is fine. Thanks $\endgroup$ – KratosMath May 20 '18 at 18:04
  • $\begingroup$ I am facing one strange error for some pairs of gifs. It says "ImageAssemble::row: Expecting images of the same height in one row." Do you know how to deal with it? $\endgroup$ – KratosMath May 20 '18 at 18:14
  • $\begingroup$ Resize the images to a common height. $\endgroup$ – bill s May 20 '18 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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