(Original) on the use imagemagick to gif image, or superimposed on the canvas method, and incurable diseases

    Today, because of the project, there is a small demand, you need to specify a gif of the specified size, superimposed to the specified location on the canvas, I have been familiar with this person, simply a piece of cake Ha, but I am because of imagemagick not familiar with, leading to grope for a day before we can solve the problem on the demand, so to write this blog, to prevent post-forgotten this process.

 The first step needs are, the GIF adjust to the specified sizes:

  Use the command: convert 5832.gif -coalesce -resize 92x92 92.gif!

  This command is mandatory gif input is adjusted to the specified size, in which different pictures and adjust, this is more of a middle coalesce option, this is specifically for GIF animation sequence.

       The effect of synthesized as follows:

  The second step is a demand for the adjusted GIF this sequence, a transparent overlay to size up the canvas, the position coordinates of the specified superimposition

     First use the command:

  convert -size 191x191 xc:none null: 92.gif -geometry +99+2 -layers Composite -loop 0 33.gif

     Synthesized image ghosting effect, the effect of:

     Then find a problem for a long time, adjusting the command:

    convert ( -size 483x483 xc:none )  ( 5832.gif -coalesce -resize 643x643! -repage +68+64 )  773_0.gif

 GIF solution ghosting effect, the effect of synthesized as shown:

 This time thought completely solve the problem, the results of the test students tested several examples of current GIF image is larger than the canvas when the canvas over a range of time, there is a problem, if need be after this synthesis throw GIF ffmpeg decoding process performed, or after the synthesis gif turn into mp4, there have been the following problem:

 

By address this situation, and the source ffmpeg, I suspect that the header files gif in the width and height and width and height of the image time image caused by the inconsistency, so continue to command mode and adjustment, adjusted as follows:

convert -size 484x484 xc:none null: "(" 5832.gif -coalesce -resize 643x643! ")" -coalesce -repage +68+64 -crop 484x484+0+0 +repage -loop 0 ./773_0.gif

Fix the problem ghosting and ffmpeg decoding the format described above.

 

Guess you like

Origin www.cnblogs.com/lihaiping/p/11425849.html