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
image sequence mpr:gif[1]
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: image sequence mpr:gif[1]
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
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
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: image sequence mpr:gif[1]
You need to say mpr: when reading too..
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.
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
I have not tested so am not certain you can use image indexing with mpr. let us know.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: image sequence mpr:gif[1]
As far as i tried mpr indexing did not work
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: image sequence mpr:gif[1]
Thanks for the confirmation.
However as MPR reads are simply clones. it is FAST to simply do...
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!
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)
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... \) \
...
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 \
...
I would like to add a (while image loop) type construct for IM7 to implement 'mogrify' functionality in IM scripts)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/