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.
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.
Here's the morph animation
*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
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.
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
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:
- Duplicate the image layer, and desaturate it to obtain a grayscale copy
- Create N copies of the color layer, and interleave N copies of the grayscale layer (with grayscale on top)
- Set the opacity of each grayscale layers to decreasing values
- Merge down the grayscale layers into the color layer
- Duplicate all layers except first and last and put then on top, in reverse order.
- Steps 2-4 above can be done with the
progressive-mergescript 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-layersscript that you'll find at the same place, and which is documented here.
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).