Javascript-PHP Image Generation

Source: Internet
Author: User
Make a js editor and submit it to the PHP backend to generate an image. Because of the special requirements of the customer, if the Editor contains the following DIV, ask how to precisely display the coordinates in the generated image {code ...} in fact, the segmentfault text occupies less than 400 pixels in width. If the text is left, then... I am working on a js editor and submit it to the PHP backend to generate an image. Due to the special requirements of the customer, if the Editor contains the following DIV, I would like to ask how to precisely display coordinates in the generated image.

segmentfault

In fact, the segmentfault text occupies less than 400 pixels in width. If the text is left, it can be accurately obtained and generated based on the relative positioning of the DIV. However, if the text is centered or right, The DIV is used to locate the text, the location generated in php gd is incorrect. So how can I locate the text of the recipient?

Reply content:

I am working on a js editor and submit it to the PHP backend to generate an image. Due to the special requirements of the customer, if the Editor contains the following DIV, I would like to ask how to precisely display coordinates in the generated image.

segmentfault

In fact, the segmentfault text occupies less than 400 pixels in width. If the text is left, it can be accurately obtained and generated based on the relative positioning of the DIV. However, if the text is centered or right, The DIV is used to locate the text, the location generated in php gd is incorrect. So how can I locate the text of the recipient?

Just two days ago,
You need to put a piece of p on the page,
Html2canvas found online
Js sends the data to the backend php to generate an image, which can be used (chrome, firefox ),
But not compatible with browsers earlier than ie9 !!!
Miserable

GD can locate the text or center the text. You can refer to the imagettfbbox function on the right. However, according to my impression, the results of this function are often inaccurate (especially for some special fonts ), we recommend that you use the imagick extension to generate images.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.