{"id":17648231,"url":"https://github.com/miikanissi/zebrafy","last_synced_at":"2025-09-09T19:32:23.480Z","repository":{"id":188834439,"uuid":"674746132","full_name":"miikanissi/zebrafy","owner":"miikanissi","description":"Python library for converting PDF and images to and from Zebra Programming Language (ZPL).","archived":false,"fork":false,"pushed_at":"2024-11-27T06:49:58.000Z","size":3029,"stargazers_count":47,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-20T09:17:14.382Z","etag":null,"topics":["gfa","pdf-converter","python","zebra-printer","zebra-programming-language","zpl","zpl-programming-language"],"latest_commit_sha":null,"homepage":"https://zebrafy.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miikanissi.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-04T17:02:56.000Z","updated_at":"2024-12-12T09:44:26.000Z","dependencies_parsed_at":"2024-06-22T15:58:03.944Z","dependency_job_id":"f929a97f-3c8c-4954-ac71-56996e030bfa","html_url":"https://github.com/miikanissi/zebrafy","commit_stats":null,"previous_names":["miikanissi/zebrafy"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miikanissi%2Fzebrafy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miikanissi%2Fzebrafy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miikanissi%2Fzebrafy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miikanissi%2Fzebrafy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miikanissi","download_url":"https://codeload.github.com/miikanissi/zebrafy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393569,"owners_count":20931812,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gfa","pdf-converter","python","zebra-printer","zebra-programming-language","zpl","zpl-programming-language"],"created_at":"2024-10-23T11:16:59.723Z","updated_at":"2025-04-05T20:06:24.616Z","avatar_url":"https://github.com/miikanissi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"|zebrafy_icon_64| Zebrafy\n=========================\n\n.. |zebrafy_icon_64| image:: https://raw.githubusercontent.com/miikanissi/zebrafy/master/docs/zebrafy-64.png\n   :alt: Zebrafy Logo\n\n.. image:: https://github.com/miikanissi/zebrafy/actions/workflows/ci.yml/badge.svg\n    :target: https://github.com/miikanissi/zebrafy/actions/workflows/ci.yml\n    :alt: CI\n\n.. image:: https://readthedocs.org/projects/zebrafy/badge/?version=latest\n    :target: https://zebrafy.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\n.. image:: https://img.shields.io/pypi/v/zebrafy\n    :target: https://pypi.org/project/zebrafy\n    :alt: Zebrafy PyPi Package\n\n.. image:: https://img.shields.io/badge/license-LGPLv3-green\n    :target: https://www.gnu.org/licenses/lgpl-3.0.en.html#license-text\n    :alt: License\n\n**Zebrafy** is a Python 3 library for converting PDF and images to and from\n`Zebra Programming Language (ZPL) \u003chttps://en.wikipedia.org/wiki/Zebra_Programming_Language\u003e`_\ngraphic fields (^GF).\n\n**Zebrafy** consists of three conversion tools:\n\n- **ZebrafyImage** — convert an image into valid ZPL\n- **ZebrafyPDF** — convert a PDF into valid ZPL\n- **ZebrafyZPL** — convert valid ZPL graphic fields into images or PDF\n\nIf you want more control over the resulting ZPL data, **ZebrafyImage** and\n**ZebrafyPDF** support the following optional parameters:\n\n+-----------------------+--------------------------------------------------------------------------------------------------------------+\n| Parameter             | Description                                                                                                  |\n+=======================+==============================================================================================================+\n| ``format``            | ZPL graphic field format type (default ``\"ASCII\"``)                                                          |\n|                       |                                                                                                              |\n|                       | - ``\"ASCII\"`` — ASCII hexadecimal (most compatible)                                                          |\n|                       | - ``\"B64\"`` — Base64 Binary                                                                                  |\n|                       | - ``\"Z64\"`` — Z64 compressed binary (best compression)                                                       |\n+-----------------------+--------------------------------------------------------------------------------------------------------------+\n| ``invert``            | Invert the black and white in the image/PDF output. (``True`` or ``False``, default ``False``)               |\n+-----------------------+--------------------------------------------------------------------------------------------------------------+\n| ``dither``            | Dither the result instead of hard limit on black pixels. (``True`` or ``False``, default ``True``)           |\n+-----------------------+--------------------------------------------------------------------------------------------------------------+\n| ``threshold``         | Black pixel threshold for image without dithering (``0-255``, default ``128``)                               |\n+-----------------------+--------------------------------------------------------------------------------------------------------------+\n| ``width``             | Width of the image in the resulting ZPL, ``0`` to use original image/PDF width (default ``0``)               |\n+-----------------------+--------------------------------------------------------------------------------------------------------------+\n| ``height``            | Height of the image in the resulting ZPL, ``0`` to use original image/PDF height (default ``0``)             |\n+-----------------------+--------------------------------------------------------------------------------------------------------------+\n| ``pos_x``             | Pixel x position of the graphic field in resulting ZPL (default ``0``)                                       |\n+-----------------------+--------------------------------------------------------------------------------------------------------------+\n| ``pos_y``             | Pixel y position of the graphic field in resulting ZPL (default ``0``)                                       |\n+-----------------------+--------------------------------------------------------------------------------------------------------------+\n| ``rotation``          | Rotates the image by the specified degree (``0``, ``90``, ``180`` or ``270``, default ``0``)                 |\n+-----------------------+--------------------------------------------------------------------------------------------------------------+\n| ``string_line_break`` | Number of characters in graphic field content after which a line break is inserted (default ``None``)        |\n+-----------------------+--------------------------------------------------------------------------------------------------------------+\n| ``complete_zpl``      | Add ZPL header and footer or only get the ZPL graphic field output (``True`` or ``False``, default ``True``) |\n+-----------------------+--------------------------------------------------------------------------------------------------------------+\n\nAdditionally, **ZebrafyPDF** supports the following optional parameters:\n\n+-----------------------+-----------------------------------------------------------------------------------------------------------------------+\n| Parameter             | Description                                                                                                           |\n+=======================+=======================================================================================================================+\n| ``dpi``               | Pixels per PDF canvas unit, defines resolution scaling of the PDF image (\u003c72: compress, \u003e72: stretch, default ``72``) |\n+-----------------------+-----------------------------------------------------------------------------------------------------------------------+\n| ``split_pages``       | Split the PDF into separate ZPL labels for each page (``True`` or ``False``, default ``False``)                       |\n+-----------------------+-----------------------------------------------------------------------------------------------------------------------+\n\n\nGetting Started\n---------------\n\nInstallation\n^^^^^^^^^^^^\n\n.. code-block:: console\n\n  pip install zebrafy\n\n\nDependencies\n^^^^^^^^^^^^\n\nPip handles all dependencies automatically. This library is built on top of:\n\n- `Pillow \u003chttps://pillow.readthedocs.io/\u003e`_ — Python Imaging Library\n- `pypdfium2 \u003chttps://github.com/pypdfium2-team/pypdfium2\u003e`_ — Python 3 binding to\n  `PDFium \u003chttps://pdfium.googlesource.com/pdfium/+/refs/heads/main\u003e`_\n\nExample Usage\n^^^^^^^^^^^^^\n\nImage to ZPL Graphic Field with **ZebrafyImage**\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\nConvert image bytes into a complete ZPL string and save to file:\n\n.. code-block:: python\n\n  from zebrafy import ZebrafyImage\n\n  with open(\"source.png\", \"rb\") as image:\n      zpl_string = ZebrafyImage(image.read()).to_zpl()\n\n  with open(\"output.zpl\", \"w\") as zpl:\n      zpl.write(zpl_string)\n\nExample usage with optional parameters:\n\n.. code-block:: python\n\n  from zebrafy import ZebrafyImage\n\n  with open(\"source.png\", \"rb\") as image:\n      zpl_string = ZebrafyImage(\n          image.read(),\n          format=\"Z64\",\n          invert=True,\n          dither=False,\n          threshold=128,\n          width=720,\n          height=1280,\n          pos_x=100,\n          pos_y=100,\n          rotation=90,\n          string_line_break=80,\n          complete_zpl=True,\n      ).to_zpl()\n\n  with open(\"output.zpl\", \"w\") as zpl:\n      zpl.write(zpl_string)\n\nAlternatively, **ZebrafyImage** also accepts PIL Image as the image parameter instead of\nimage bytes:\n\n.. code-block:: python\n\n  from PIL import Image\n  from zebrafy import ZebrafyImage\n\n  pil_image = Image.new(mode=\"RGB\", size=(100, 100))\n  zpl_string = ZebrafyImage(pil_image).to_zpl()\n\n  with open(\"output.zpl\", \"w\") as zpl:\n      zpl.write(zpl_string)\n\n\nPDF to ZPL Graphic Field with **ZebrafyPDF**\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\nConvert PDF bytes into a complete ZPL string and save to file:\n\n.. code-block:: python\n\n  from zebrafy import ZebrafyPDF\n\n  with open(\"source.pdf\", \"rb\") as pdf:\n      zpl_string = ZebrafyPDF(pdf.read()).to_zpl()\n\n  with open(\"output.zpl\", \"w\") as zpl:\n      zpl.write(zpl_string)\n\n**ZebrafyPDF** conversion supports the same optional parameters as **ZebrafyImage**\nconversion, with the addition of the ``split_pages`` parameter to split the PDF pages:\n\n.. code-block:: python\n\n  from zebrafy import ZebrafyPDF\n\n  with open(\"source.pdf\", \"rb\") as pdf:\n      zpl_string = ZebrafyPDF(\n          pdf.read(),\n          format=\"Z64\",\n          invert=True,\n          dither=False,\n          threshold=128,\n          dpi=72,\n          width=720,\n          height=1280,\n          pos_x=100,\n          pos_y=100,\n          rotation=90,\n          string_line_break=80,\n          complete_zpl=True,\n          split_pages=True,\n      ).to_zpl()\n\n  with open(\"output.zpl\", \"w\") as zpl:\n      zpl.write(zpl_string)\n\nZPL to PDF or Images with **ZebrafyZPL**\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\nConvert all graphic fields from a valid ZPL file to PIL Images and save to image files:\n\n.. code-block:: python\n\n  from zebrafy import ZebrafyZPL\n\n  with open(\"source.zpl\", \"r\") as zpl:\n      pil_images = ZebrafyZPL(zpl.read()).to_images()\n      for count, pil_image in enumerate(pil_images):\n          pil_image.save(f\"output_{count}.png\", \"PNG\")\n\nConvert all graphic fields from a valid ZPL file to PDF bytes and save to PDF file:\n\n.. code-block:: python\n\n  from zebrafy import ZebrafyZPL\n\n  with open(\"source.zpl\", \"r\") as zpl:\n      pdf_bytes = ZebrafyZPL(zpl.read()).to_pdf()\n\n  with open(\"output.pdf\", \"wb\") as pdf:\n      pdf.write(pdf_bytes)\n\n\nContributing and Issues\n-----------------------\n\nContributions and bug reports are welcome and can be submitted on the\n`GitHub page \u003chttps://github.com/miikanissi/zebrafy\u003e`_.\n\nThe project does not yet have a well-defined scope, and I'm open to new feature\nrequests. Features currently in consideration are:\n\n- HTML to ZPL conversion by implementing standard HTML elements into ZPL commands\n- Extract text from a PDF to render it as a native ZPL command instead of graphic field\n\nLicense\n-------\n\nThis source is released under the\n`GNU Lesser General Public License v3.0 \u003chttps://www.gnu.org/licenses/lgpl-3.0.en.html#license-text\u003e`_.\n\nLogo\n----\n\n.. image:: https://raw.githubusercontent.com/miikanissi/zebrafy/master/docs/zebrafy-long.png\n   :alt: Zebrafy Logo\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiikanissi%2Fzebrafy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiikanissi%2Fzebrafy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiikanissi%2Fzebrafy/lists"}