Converting RGB image to Floyd-Steinberg image using PHP or Javascript for Zebra printers

后端 未结 1 985
一向
一向 2021-01-18 07:23

I am developing a desktop based PHP application where we need to capture image of a person and print it on the label using Zebra GC420t printer The expected im

1条回答
  •  借酒劲吻你
    2021-01-18 07:54

    Have a look at this library GDIndexedColorConverter that's a simple library that convert an image into indexed color mode.

    require 'GDIndexedColorConverter.php';
    
    // create an image
    $image = imagecreatefromjpeg('image.jpg');
    
    // create a gd indexed color converter
    $converter = new GDIndexedColorConverter();
    
    // the color palette
    $palette = array(
        array(0, 0, 0),
        array(255, 255, 255),
        array(0, 0, 0),
        array(0, 0, 0),
        array(0, 0, 0)
    );
    
    // convert the image to indexed color mode
    $new_image = $converter->convertToIndexedColor($image, $palette, 0.25);
    
    // save the new image
    imagepng($new_image, 'example_indexed_color.png', 0);
    

    Here is the input:

    And here is the output:

    0 讨论(0)
提交回复
热议问题