1590120840
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-image
and used background-position
to change the frame.
This is the spritesheet.
So now we will do like this:
gif
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 * 288px
and 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
The 2nd and 3rd parameters of drawImage
will 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);
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.createObjectURL
to create a temporary URL. Our result is like this.
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 transparent
for gif.js
like this
const gif = new GIF({
workers: 2,
quality: 1,
transparent: 'rgba(0, 0, 0, 0)',
});
Then we get results like this.
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.
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 drawImage
it will overlap the image. Our result is like this.
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
Regarding how Facebook works, why use a spritesheet without using a GIF image. Doing this also has some benefits.
But there must also be some that are not beneficial
background-image
and background-position
so the sticker size is fixed, want to change spritesheet to change.#gif #programming
1614750304
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
1614145832
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
1590660177
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:
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:
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
1599807462
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:
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:
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
1624593660
The line between the phrases âTaking your business onlineâ and âSetting up a business on Facebookâ is getting blurred.
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:
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