Search code examples
phpescpos

mike42/escpos-php - image dimension


I have a large PNG file that I would like to print it over the ESCPOS-PHP library. I knew there is something like MODE_DOUBLE_WIDTH, but my image is already in a large size so I want to make it smaller.

However I have been looking for the parameter of setting the dimension of a image file, is there any parameter to resize (set the size like 20x20) the image programmatically.


Solution

  • mike42/escpos-php will not have a function to convert the size of image data.
    The documentation doesn't mention it, and the source code doesn't have that functionality.

    If you want to convert some image data file into data of specific vertical and horizontal dot size, please use another library other than mike42/escpos-php or the function of language.


    documentation:
    graphics(EscposImage $image, $size)

    Print an image to the printer.

    Parameters:

    • EscposImage $img: The image to print.
    • int $size: Output size modifier for the image.

    Size modifiers are:

    • IMG_DEFAULT (leave image at original size)
    • IMG_DOUBLE_WIDTH
    • IMG_DOUBLE_HEIGHT

    The function bitImage() takes the same parameters, and can be used if your printer doesn't support the newer graphics commands. As an additional fallback, the bitImageColumnFormat() function is also provided.

    source code:
    escpos-php/src/Mike42/Escpos/EscposImage.php
    escpos-php/src/Mike42/Escpos/GdEscposImage.php
    escpos-php/src/Mike42/Escpos/ImagickEscposImage.php


    The specification of IMG_DEFAULT, IMG_DOUBLE_WIDTH, IMG_DOUBLE_HEIGHT is the value specified in the parameter of the ESC/POS command, not the function of converting the image data.

    ESC *
    GS /
    GS Q 0
    GS v 0