Louie Sanders

Louie Sanders

1590120840

Create gif from Facebook Sticker

Even though the Facebook and Messenger apps are bad, they have really cute stickers đŸ€Ș. But you try to download, there is no way to download as a gif file file. Anyway, it appears already, there is no way to download. Try inspecting the element, we will see it appears to be a spritesheet set background-imageand used background-positionto change the frame.

animate-spritesheet

This is the spritesheet.

tonton-inspect

So now we will do like this:

  1. Get the frames from spritesheet
  2. Merge into file gif

Split frames from spritesheet

Looking at the spritesheet up there, you can see that it has 8 frames, each size 288px * 288px. You can manually cut it out by any app. Or we will write a script to cut out. We will use the Canvas API to render frames from spritesheet.

Suppose we have a spritesheet loaded on a page like this

<img id="spritesheet" src="https://scontent.fhan5-7.fna.fbcdn.net/v/t39.1997-6/72568563_526222821444483_279572336263299072_n.png?_nc_cat=100&_nc_sid=0572db&_nc_oc=AQlkAKjDakbfs1blUQC66vLLLnC5bCz1Eh6KJf_9JCgjaxqJ4kO1GhPF-CAkq3MZqGX5m_ar6Gu7tbuCFn06FXnA&_nc_ht=scontent.fhan5-7.fna&oh=fff5b86d6e73bd2c11d359b4f5b63b96&oe=5EE5DA80">

To cut out each frame, we will create a canvas with the size 288px * 288pxand render the corresponding part on the sprite sheet onto that canvas. For example, to cut the first frame, we do like this

const spritesheet = document.getElementById('spritesheet');

const canvas = document.createElement('canvas');
canvas.width = 288;
canvas.height = 288;

const ctx = canvas.getContext('2d');
ctx.drawImage(spritesheet, 0, 0, 288, 288, 0, 0);

document.body.appendChild(canvas);

You should see the first frame like this

first_frame

The 2nd and 3rd parameters of drawImagewill be the position of the frame on the spritesheet. Document details here .

To cut all the frames, we make a loop like this

const frames = [];

while (y < spritesheet.height) {
    x = 0;

    while (x < spritesheet.width) {
        const canvas = document.createElement('canvas');
        canvas.width = canvasWidth;
        canvas.height = canvasHeight;

        const ctx = canvas.getContext('2d');
        ctx.drawImage(spritesheet, x, y, 288, 288, 0, 0);

        const isEmpty = ctx.getImageData(0, 0, canvasWidth, canvasHeight).data.every(channel => channel === 0);

        if (!isEmpty) {
            frames.push(canvas);
        }

        x += originalWidth;
    }

    y += originalHeight;
}

You will see that we have left a last empty frame empty, so I have to add a check to see if the frame we just cut has data before adding it to the array frames. Simply check whether all its pixels have data or not.

const isEmpty = ctx.getImageData(0, 0, canvasWidth, canvasHeight).data.every(channel => channel === 0);

Merge frames into GIF image

If I have frames then I can stitch them together. I will use the package [gif.js](http://npmjs.com/package/gif.js)to create gif images. Creating images from frames is as simple as this.

const fps = 8;

const gif = new GIF({
    workers: 2,
    quality: 1,
});

frames.forEach(frame => gif.addFrame(frame, {
    delay: 1000 / fps,
}));

gif.on('finished', (blob) => {
    const url = URL.createObjectURL(blob);
    const img = document.createElement('img');
    img.setAttribute('src', url);
    document.body.appendChild(img);
});

gif.render();

Just add the frames and the delay between frames then render. To make it easy to calculate, we use the concept of frame rate, often the Facebook stickers I see have frame rate from 8-12 fps. The result will be raw data so we can use URL.createObjectURLto create a temporary URL. Our result is like this.

tonton-black

It’s okay, except for the black background ra. This is because our image is partially transparent, so the gif is rendered. If add options transparentfor gif.jslike this

const gif = new GIF({
    workers: 2,
    quality: 1,
    transparent: 'rgba(0, 0, 0, 0)',
});

Then we get results like this.

tonton-black

There is a transparent background but the contours are not very good. This is due to format limitations GIF. Normally, with a transparent image such as PNG, the transition from the image to the transparent place will be a lot of pixels with reduced transparency like this to make the border of the image smooth.

tonton-edge

However, with the GIF format, each px can only be colored or completely transparent, not half transparent like PNG. So the contour looks like a low-quality serrated pattern. So a gif that has a transparent background usually has a small white border (or something similar to the background where people plan to put the gif on) to make the border look smoother. For simplicity, I will give the white background as well.

ctx.fillStyle = '#fff';
ctx.fillRect(0, 0, canvasWidth, canvasHeight);

Remember to color before drawImageit will overlap the image. Our result is like this.

tontontonton

This is the whole code if you want to play with it.

Link codepen if the embed doesn’t load 😔 https://codepen.io/thphuong/pen/qBOyRaz

Bonus

Regarding how Facebook works, why use a spritesheet without using a GIF image. Doing this also has some benefits.

  • Better photos, GIF images have 256 colors instead of 16 million colors like PNG.
  • No problem with transparent as I mentioned above anymore.
  • No need to be copied (may be đŸ€”).

But there must also be some that are not beneficial

  • No resizing. Because used background-imageand background-positionso the sticker size is fixed, want to change spritesheet to change.
  • Running RAM with CPU 🙄.

#gif #programming

What is GEEK

Buddha Community

Create gif from Facebook Sticker
Alice Cook

Alice Cook

1614750304

How can I create a Poll on Facebook?

How do I start or create or post a Poll on Facebook? Know the ways to add options or make a poll on Facebook Page or Messenger.

make a poll on Facebook
add options to Facebook Poll

#how can i create a poll on facebook #create a poll on facebook #how to make a poll on facebook #how to do a poll on facebook #poll on facebook #create poll on facebook

Harry Patel

Harry Patel

1614145832

A Complete Process to Create an App in 2021

It’s 2021, everything is getting replaced by a technologically emerged ecosystem, and mobile apps are one of the best examples to convey this message.

Though bypassing times, the development structure of mobile app has also been changed, but if you still follow the same process to create a mobile app for your business, then you are losing a ton of opportunities by not giving top-notch mobile experience to your users, which your competitors are doing.

You are about to lose potential existing customers you have, so what’s the ideal solution to build a successful mobile app in 2021?

This article will discuss how to build a mobile app in 2021 to help out many small businesses, startups & entrepreneurs by simplifying the mobile app development process for their business.

The first thing is to EVALUATE your mobile app IDEA means how your mobile app will change your target audience’s life and why your mobile app only can be the solution to their problem.

Now you have proposed a solution to a specific audience group, now start to think about the mobile app functionalities, the features would be in it, and simple to understand user interface with impressive UI designs.

From designing to development, everything is covered at this point; now, focus on a prelaunch marketing plan to create hype for your mobile app’s targeted audience, which will help you score initial downloads.

Boom, you are about to cross a particular download to generate a specific revenue through your mobile app.

#create an app in 2021 #process to create an app in 2021 #a complete process to create an app in 2021 #complete process to create an app in 2021 #process to create an app #complete process to create an app

How Much Does It Cost To Build Facebook Clone App?

It is an era of technology where we can make a clone of any app like a Facebook app or any social networking app.

In the world, each and everyone has a mobile phone/cell phone. Every user mostly uses one type of social media apps in their life for being updated with the outside virtual world.

Are you inspired by any social networking app like Facebook and want to develop a Facebook clone app? If you are a business person or an enterprise, looking to develop an app like a Facebook clone app?

How To Create The Best Facebook Clone Mobile App?

Before deciding on the mobile app development of Facebook, you need to consider its features, development time, and hourly pricing because these will affect the Facebook app cost.

Key Features Of Facebook App:

  • Registration - Mobile number or Email
  • Automatic synchronization of contact list
  • Share texts, photos, and videos instantly
  • Instant notifications
  • Play games, and discover nearby friends
  • The intuitive search option to easily find known friends by name
  • Integrated Messenger to chat with friends
  • Option to access the Facebook business page

How Much Does An App Like FB Cost?

When one wants to develop an app like Facebook, the first thing that comes to his mind is how much it costs to create a Facebook-like app. The development cost of Facebook clone app is estimated on the following key factors:

  • App Platform (Android, iOS (iPhone), or Windows)
  • App Design
  • App Size
  • App Developers

Let’s describe the overall app development cost by setting an hourly rate of $40 as the cost (based on the average Ukrainian and Indian market cost). With these known values, the total cost to develop an app (on one platform) similar in functionality to Facebook would be around $155,000.

#build facebook clone app #create a facebook like app #develop a facebook clone app #develop an app like facebook #social networking app like facebook

How much does it cost to make an app like Facebook?

It is an era of technology where we can make a clone of any app like a Facebook app or any social networking app.

In the world, each and everyone has a mobile phone/cell phone. Every user mostly uses one type of social media apps in their life for being updated with the outside virtual world.

Are you inspired by any social networking app like Facebook and want to develop a Facebook clone app? If you are a business person or an enterprise, looking to develop an app like a Facebook clone app?

How To Create The Best Facebook Clone Mobile App?

Before deciding on the mobile app development of Facebook, you need to consider its features, development time, and hourly pricing because these will affect the Facebook app cost.

Key Features Of Facebook App:

  • Registration - Mobile number or Email
  • Automatic synchronization of contact list
  • Share texts, photos, and videos instantly
  • Instant notifications
  • Play games, and discover nearby friends
  • The intuitive search option to easily find known friends by name
  • Integrated Messenger to chat with friends
  • Option to access the Facebook business page

How Much Does An App Like FB Cost?

When one wants to develop an app like Facebook, the first thing that comes to his mind is how much it costs to create a Facebook-like app. The development cost of Facebook clone app is estimated on the following key factors:

  • App Platform (Android, iOS (iPhone), or Windows)
  • App Design
  • App Size
  • App Developers

Let’s describe the overall mobile app development cost by setting an hourly rate of $40 as the cost (based on the average Ukrainian and Indian market cost). With these known values, the total cost to develop an app (on one platform) similar in functionality to Facebook would be around $155,000.

#make a facebook clone app #make an app like facebook #cost to make an app like facebook #make a social media app like facebook #how to create an app like facebook

Erwin  Boyer

Erwin Boyer

1624593660

1​5 Reasons For Business To Get Facebook Chatbot

Introduction

The line between the phrases “Taking your business online” and “Setting up a business on Facebook” is getting blurred.

Source

With more than 30% of the world’s population (approximately 2.41 billion people) active every month on Facebook, there is no reason why your brand should not have a Facebook page of its own. To further support this claim, Americans alone spend approximately 20% of their day on Facebook or other platforms that Facebook owns.

So, sit back and think of the enormity of the market you would be able to reach with just a few clicks on the keyboard. But therein lie a few problems:

  • How can you cater to the massive audience when queries start to arise?
  • How can you leverage Facebook for marketing without denting your cash reserves?
  • How can you ensure that all your fans and followers get a personalized experience when interacting with your brand?

By now, you already know the answer from the title – get a Facebook Chatbot!

In this article, you will learn how a Messenger bot will help your business in 15 different ways, supported with rich examples, statistics, and use cases.

#facebook-marketing #facebook #facebook-messenger #facebook-messenger-chatbot #social-media-marketing #chatbots #social-media #customer-support-chatbots