Is it possible to merge a image1.gift and image2.jpg with .net or javascript?

I want to merge two Images one of them is gif like this: enter image description here

and other one is this:

enter image description here

Now I want put the second image in the gray box of first image. Is it possible to do that with .net or javascript?

Upvotes: 1

Views: 252

Answers (1)

Stefan Steiger
Stefan Steiger

Reputation: 82316

To answer the question - Yes ;)

OK, now how:

First, you need to find a way to read the gif image you have.
Example in C# here:
https://dejanstojanovic.net/aspnet/2018/march/getting-gif-image-information-using-c/

Then you probably need to take the GIF-Frame(s), and convert it into PNG, copy the the jpeg image at the correct location, then convert the png back to gif, and then create a new gif using https://github.com/mrousavy/AnimatedGif and set all the frames to the same time as in the original.

For JavaScript, there is libgif-js for the browser, and gif-encoder-2 from npm for NodeJS.
Or you can choose the batch route with ffmpeg.

Code on github

ImageSharp:

with ImageSharp

GDI:

with System.Drawing

ImageSharp - no repeat:

with ImageSharp without repeat

Upvotes: 2

Related Questions