PHP Generate food order small ticket picture, how the length of the picture fit content?

Source: Internet
Author: User
In a food and beverage system, first use PHP to generate a good order ticket, and then stored in the directory. The Python script periodically detects the directory and passes it to the printer when there is a picture.
Now encountered a problem is that the PHP generated image is to specify the width of the high, but some orders more or less dishes, resulting in the length of the order ticket content is different, in PHP how to generate a picture of fit content? Think for a long time have no clue, please help.

Reply content:

In a food and beverage system, first use PHP to generate a good order ticket, and then stored in the directory. The Python script periodically detects the directory and passes it to the printer when there is a picture.
Now encountered a problem is that the PHP generated image is to specify the width of the high, but some orders more or less dishes, resulting in the length of the order ticket content is different, in PHP how to generate a picture of fit content? Think for a long time have no clue, please help.

Can be used imagettfbbox to get the width height of the bounding rectangle generated by the specified text under the TTF font

It's easy to assume that a blank menu picture has a minimum length of 10cm, a dish, and a 1cm image length. When generated, calculate how many items are in the menu.
Then the length will be adaptive.
Picture length = Minimum length + number of items * length to be added per item

Calculate the height before generating the picture.

  • 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.