Page 1 of 1
image sequence mpr:gif[1]
Posted: 2012-08-17T06:33:17-07:00
by Marcel71
I have an animated gif where i want to do some editing on each seperate frame.
So i thought of doing something like:
convert (img.gif[0] -do_sth) (img.gif[1] -do_sth) (img.gif[2] -do_sth ) etc.. out.gif
However, in above example the image is read from disk 3 times.
But the following is not working:
convert img.gif -write mpr:gif +delete ( img:gif[0] -do_sth ) ( img:gif[1] -do_sth ) ( img:gif[2] -do_sth) out.gif
Is there a way to read the image one time in memory and then call the seperate frames?
Regards,
Marcel
Re: image sequence mpr:gif[1]
Posted: 2012-08-17T09:54:21-07:00
by fmw42
I do not think that mpr names will accept frame numbers. Also when you use the mpr file you have to use mpr:name.
I think you really want to use clones rather than mpr. The clones can access each frame of the original image. See clones and parenthesis processing. For an input image with 3 frames, -clone 0 will be frame 0, -clone 1 will be frame 1, etc. see
http://www.imagemagick.org/Usage/basics/#list_ops
Also note that parentheses need spaces between them and the code inside
If you are doing the same thing to each frame, you do not need to apply that to each frame separately. You can apply it to the whole animation. If necessary you can use -coalesce to separate the frames and just apply your processing.
convert animation.gif <processing> new_animation.gif
or
convert animatin.gif -coalesce <processing> new_animation.gif
Re: image sequence mpr:gif[1]
Posted: 2012-08-23T18:57:38-07:00
by anthony
You need to say mpr: when reading too..
Code: Select all
convert img.gif -write mpr:gif +delete ( 'mpr:gif[0]' -do_sth ) ( 'mpr:gif[1]' -do_sth ) ( 'mpr:gif[2]' -do_sth) out.gif
Don't forget to escape the [] chararcter from the shell.
I have not tested so am not certain you can use image indexing with mpr. let us know.
Re: image sequence mpr:gif[1]
Posted: 2012-08-28T04:38:24-07:00
by Marcel71
As far as i tried mpr indexing did not work
Re: image sequence mpr:gif[1]
Posted: 2012-09-02T18:45:24-07:00
by anthony
Thanks for the confirmation.
However as MPR reads are simply clones. it is FAST to simply do...
Code: Select all
... image.gif -write mpr:gif -delete 0--1 .... \
\( mpr:gif -swap 0,N -delete 1--1 ..work on image index N... \) \
...
Where 'N' is the image index (starting at 0) you want to work on.
That is get images, move index to front and delete rest (for now)
But then you don't even need MPR for this! Just work on the index and replace the original!
Code: Select all
... image.gif .... \
\( -clone N ..work on image index N... \) -swap N +delete \
...
The only problem is that at this point IM has no - loop over each image one at a time, facility.
I would like to add a (while image loop) type construct for IM7 to implement 'mogrify' functionality in IM scripts)