Reversing a film strip

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Locked
nbacklund
Posts: 2
Joined: 2020-02-25T04:34:34-07:00
Authentication code: 1152

Reversing a film strip

Post by nbacklund »

Hi!

I am building a GUI using vertical filmstrips, i e animation frames layed out vertically in a single .png file.

I have an old filmstrip that has 65 frames, with a size of 60x55 px each (so the total file dimensions are 60x3575).
I would like to crop the first 33 frames and then reverse the order of the frames in that sequence.

Could this be done from the command line version of Image Magick, and if this is the case, how do I do it?
It seems that this is a very powerful tool, but the number of options is daunting to say the least, and I'm also not very familiar with the terminology which makes it even harder to find the information that I need...

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Reversing a film strip

Post by snibgo »

What version of IM, on what platform? I'll assume v7 on Windows.

So you want just 33 frames in the output, appended vertically?

I would do it like this:

1. Crop out just the first 33 frames.

2. Crop these into 33 images.

3. Reverse the sequence.

4. Append them together.

https://www.imagemagick.org/script/comm ... ptions.php gives the operations: -crop, -reverse and -append.

You haven't shown a sample input, so I can't test this, but...

Code: Select all

magick ^
  in.png ^
  -crop 60x1815+0+0 +repage ^
  -crop 60x55 +repage ^
  -reverse ^
  -append +repage ^
  out.png
snibgo's IM pages: im.snibgo.com

User avatar
GeeMack
Posts: 757
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Reversing a film strip

Post by GeeMack »

nbacklund wrote:
2020-02-25T04:43:53-07:00
I have an old filmstrip that has 65 frames, with a size of 60x55 px each (so the total file dimensions are 60x3575).
I would like to crop the first 33 frames and then reverse the order of the frames in that sequence.
There are several ways to accomplish this with ImageMagick. If you want to reverse the order of the first 33 frames then re-append them to the beginning of the strip, a command like this should do it...

Code: Select all

convert strip.png -crop 1x65@ ( -clone 0-32 -reverse -append ) -delete 0-32 +insert -append 65frames.png
That starts by cropping the entire strip into all its individual frames. Then inside the parentheses it reverses the first 33 and appends them together. After the parentheses it deletes the original 33 frames, moves that reversed and appended bunch of frames back to the beginning, and appends the whole thing together.

If you're on a *nix OS you'll probably have to escape those parentheses with backslashes "\(...\)".

If you just want to take the first 33 frames, reverse them, append them together, and save just that 33 frame piece, it could be as simple as this...

Code: Select all

convert strip.png -crop 1x65@ -delete 33--1 -reverse -append 33frames.png
That just crops the whole strip into 65 frames, deletes all the frames beyond the first 33, reverse the 33, and re-appends them.

nbacklund
Posts: 2
Joined: 2020-02-25T04:34:34-07:00
Authentication code: 1152

Re: Reversing a film strip

Post by nbacklund »

snibgo wrote:
2020-02-25T05:41:39-07:00
What version of IM, on what platform? I'll assume v7 on Windows.

So you want just 33 frames in the output, appended vertically?

I would do it like this:

1. Crop out just the first 33 frames.

2. Crop these into 33 images.

3. Reverse the sequence.

4. Append them together.

https://www.imagemagick.org/script/comm ... ptions.php gives the operations: -crop, -reverse and -append.

You haven't shown a sample input, so I can't test this, but...

Code: Select all

magick ^
  in.png ^
  -crop 60x1815+0+0 +repage ^
  -crop 60x55 +repage ^
  -reverse ^
  -append +repage ^
  out.png
Wow, thanks, this worked perfectly!
I think I'm going to put some more effort into learning this tool properly now.

Sorry for not specifying my environment, I'm on macOS 10.12. :)

Thanks again!

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Reversing a film strip

Post by fmw42 »

Mac (Unix) syntax would need to replace the ^ with \

Locked