2

Say a portrait is in color, and you duplicate it but in black-and-white. How to create an animation as .png using Gimp that cycles between the two images by gradually morphing them together in a loop back-and-forth? Online morphing editor doesn't have an option to save the output.

1
  • if this is for the web, you can uses css filters: filter: grayscale(100%); and javascript to alter the percentage vale. just one image.
    – Yorik
    Feb 1, 2022 at 15:05

2 Answers 2

5

There's a plugin for GIMP called G'MIC* which has an animated Morph feature as well as many other filters. It also works in Photoshop and Krita.

Once installed it's located at Filters > G'MIC Qt > Deformations > Morph (interactive). Instructions appear in the Window of the plugin. Basically you set it up by applying points to a source image on one layer, and then move them to a target layer. For example, this is a horse to cow morph. When you've finished placing all your points hit Q, and it will make the animation.

For something like a colour to black and white morph which is even simpler, you wouldn't need to add these points, and it will just create something like a tween between the two image layers.

enter image description here

Here's the morph animation

enter image description here

*Note: I have no affiliation with G'MIC. Also for animation on the web better to export as GIF. PNG itself is not an animation format, although there is an APNG format, not sure how well supported it is, especially in older browsers.

Here's another example made with the same filter, this one just has four layers to start with, the first is colour, second B&W, third B&W, and the fourth colour. This gives the effect of going from colour to black and white, then back to colour.

Here is the layer arrangement

enter image description here

Now run the Morph (interactive) filter in G'MIC, make sure to set it to "all layers", hit OK, and then close two little preview Windows that open. That will initiate the filter.

enter image description here

To Export do File > Export As, type a new file name and end with the file extension .gif. Click Export, and choose "as animation", then hit Export

4
  • Steps for where gmic comes in for the steps of approach 2 (manually make 4 layers)?
    – user610620
    Feb 1, 2022 at 13:36
  • Yes, but you only need one colour image, and one black and white image. The others are just duplicates. Right click the layer, and select Duplicate Layer. I used four layers so that the transitions are of equal duration.
    – Billy Kerr
    Feb 1, 2022 at 13:42
  • No i mean where does Gmic come in
    – user610620
    Feb 1, 2022 at 14:14
  • @user610620 - after making the four layers, you run the G'MIC Morph Interactive filter. Sorry I though it was obvious. I've added an explanation to the answer.
    – Billy Kerr
    Feb 1, 2022 at 14:23
1

You can't have an animated PNG, there is an APNG format but no well supported. If you want an animation in Gimp, it's either

  • GIF: very well supported, but limited to 256 colors and no partial opacity,
  • WebP: supported by all browsers now (but server software may not handle them correctly), has no color or opacity limit, and can do lossless (PNG-like) or lossy (JPEG-like) compression.

For your problem:

  1. Duplicate the image layer, and desaturate it to obtain a grayscale copy
  2. Create N copies of the color layer, and interleave N copies of the grayscale layer (with grayscale on top)
  3. Set the opacity of each grayscale layers to decreasing values
  4. Merge down the grayscale layers into the color layer
  5. Duplicate all layers except first and last and put then on top, in reverse order.

Now,

  • Steps 2-4 above can be done with the progressive-merge script that you will find here (once installed, it will appear at the bottom of the Image menu in the toolbar)(this script creates a new image)
  • Step 5 can be done using the mirror-layers script that you'll find at the same place, and which is documented here.

Color to gray and back

Note: you have to work in "RGB" mode (not color-indexed) because during the construction phase you need partial layer opacity and this isn't supported in color-indexed images. When you export to GIF, the image is automatically color indexed but there are no options. Doing the conversion explicitly before export (Image > Mode > Indexed) gives more options (especially dithering ones).

2
  • Can imgur use webp? Has anybody tested?
    – joojaa
    Feb 1, 2022 at 18:22
  • Imgur doesn't support uploads of WebP as far as I can tell. Which is weird, considering that the same Imgur will sometimes reencode your GIF as a WebP.
    – xenoid
    Feb 1, 2022 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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