Facebook有趣的应用程序如何根据获取的信息创建图像? [英] How does Facebook fun apps create images from information fetched?
问题描述
这东西真令人讨厌.实际上,我知道如何使用 html2canvas 库将HTML转换为图像.但我只想知道大多数拥有Facebook有趣应用的人,例如此和此,创建图片.
This thing is really irritating. Actually I know how to convert HTML to image using html2canvas library. But I just want to know how most of the people who have Facebook fun apps like this and this, create images.
我可以使用 FB API 获取所有必需的用户信息,然后如何创建像它们一样的JPG/PNG图片?我尝试过的是html2canvas
,但我认为其他所有有趣的应用程序都不会使用此功能.因为查看它们的源代码时,我看不到包含需要使用html2canvas
生成的图像的所有内容的HTML元素.甚至画布元素都不存在.仅显示图像.
I can get all the required user information using FB API, then how should I create an JPG/PNG image like them? What I have tried is html2canvas
but I don't think all other fun apps use this thing. Because when viewed their source code, I couldn't see the HTML element containing all the content of the image that needs to be generated using html2canvas
. Even the canvas element is NOT present. Only the image is displayed.
因此,可能有 3 种可能性:
So, there can be 3 possibilities:
-
他们使用Ajax在单独的HTML/PHP页面中进行整个处理(这是另一个问题,我进行了很多搜索,但找不到与之相关的单个答案:请参见下面的查询).
They do whole processing in a separate HTML/PHP page using Ajax (Which is another question, I searched a lot but couldn't find single answer related to that: See Query below).
它们确实使用z-index或其他内容隐藏 HTML 及其对应的 CANVAS 元素,并且仅显示生成的图像.
They do hide the HTML and its corresponding CANVAS element using z-index or something and show only generated image.
他们不使用html2canvas
.他们使用其他东西.
They don't use html2canvas
. They use something else.
与 1 相关的
查询:Ajax调用是否可以执行包含JS,CSS的HTML页面(例如URL: 'convertAndReturnImage.php'
并呈现结果并返回生成的结果)使用success
功能中的html2canvas
图像/URL ?
Query related to 1: Is it possible for Ajax call to execute an HTML page including JS, CSS (say URL: 'convertAndReturnImage.php'
and render the result and return the generated image/URL using html2canvas
in success
function?
推荐答案
您可以轻松地在服务器上组合图像-将所有图像发送到服务器,并使用特定的x/y坐标放置它们.例如,PHP为此提供了许多功能: http://php.net/manual/de/ref.image.php
You can easily combine images on the server - send all images to the server and place them with specific x/y coordinates. For example, PHP offers a lot of functions for this: http://php.net/manual/de/ref.image.php
您还可以将图片与画布组合在一起( https ://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/drawImage ),当然,请使用"toDataURL"功能并将其发送到服务器.但是您必须在服务器上创建它.例如:将画布解码为dataURL
You can also just combine the picture with canvas (https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage), use the "toDataURL" function and send it to the server, of course. But you have to create it on the server. For example: Decoding a canvas todataURL
您可以使用AJAX返回图片,也可以在服务器上创建图片并将URL返回.
You can either return the picture with AJAX or create it on the server and return the URL to it.
这篇关于Facebook有趣的应用程序如何根据获取的信息创建图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!