Package: gs1-compression
GS1 Digital Link Decompression Prototype in PythonThis package is a Python conversion of theGS1 digital link compression prototypein Javascript.BackgroundExamplesInstallationUsageContributorsDisclaimerLicenseBackgroundThe GS1 identification system is widely used worldwide within product barcodes, as well as within barcodes for shipments, assets, locations and so on.Further information about GS1 can be found athttps://www.gs1.orgDetails about the GS1 identification system and GS1 Application Identifiers can be found in the GS1 General Specifications athttps://www.gs1.org/docs/barcodes/GS1_General_Specifications.pdfand a searchable list of GS1 Application Identifiers is athttps://www.gs1.org/standards/barcodes/application-identifiers?lang=enGS1 Digital Link is a new Web URI syntax for expressing GS1 Application Identifiers and their values in a Web-friendly format, to make it easier to connect identifiers of products, shipments, locations, assets etc. to related online information and services on the Web via simple Web redirects using Web resolver infrastructure.The GS1 Digital Link syntax is defined inhttps://www.gs1.org/standards/Digital-Link/1-0A demonstration tool is available athttps://id.gs1.org/uritoolalthough it does not currently use this toolkitSee alsohttps://github.com/gs1/digital-link.jsfor a related toolkit for GS1 Digital LinkExamplesThe following example uses the all-numeric application identifier01to indicate GTIN.https://id.gs1.org/01/09780345418913The following example uses short textsgtinlotandexpdtto indicate GTIN, lot number and expiry date. A non-GS1 key-value pair{'k1': 'v1'}also appeared in this example.https://id.gs1.org/gtin/05412345000013/lot/ABC%26%2B123?expdt=1903061658&k1=v1InstallationTo install, make sure Python3 is installed, and installation in a virtual environment is preferred.$ pip install --upgrade gs1-compressionUsageDecompressionTo decompress a compressed GS1 Digital Link URI, importdecompress_gs1_digital_link:>>> from gs1 import decompress_gs1_digital_linkAn example of decompression:>>> compressed_uri = "https://id.gs1.org/ARHKVAdpQg"
>>> original_link = decompress_gs1_digital_link(compressed_uri, use_short_text=False)
>>> print("Original Link: " + original_link)
    Original Link: https://id.gs1.org/01/09780345418913Thedecompress_gs1_digital_linkfunction has two parameters.Set the second parameter,use_short_text=Trueif you prefer the GS1 Digital Link URI
to use alphabetic mnemonic short names as defined in the GS1 Digital Link standard, e.g. /gtin/.
Set itFalseif you prefer the GS1 Digital Link URI to use all-numeric GS1
application identifiers, e.g./01/.CompressionTo compress a full-length GS1 digital link, importcompress_gs1_digital_link:>>> from gs1 import compress_gs1_digital_linkA code snippet of GS1 digital link compression:>>> full_uri = "https://id.gs1.org/gtin/9421902960055/lot/2010005828/ser/xyz1234"
>>> compressed_link = compress_gs1_digital_link(digital_link_uri=full_uri, use_optimizations=False, compress_other_key_value_pairs=False)
>>> print("Compressed Link: " + compressed_link)
    Compressed Link: https://id.gs1.org/AREjalurbiAUO-cgohCz45Z67b8AThere are four parameters in the function:Pass the full length URI in thedigital_link_uriparameter.Pass the URI prefix in theuri_stemparameter. Normally you might want to be the same as the full-length URI's prefix.Setuse_optimizations=Trueif you would like to use optimized encoding of GS1 application identifiers and save more characters in the compressed string. By default, it's set to beFalse.Setcompress_other_key_value_pairs=Trueif you would like to compress non-GS1 key-value pairs in the full URI. By default, it's set to beFalse.ContributorsDi Zhudi.zhu@trust.codesSponsorsTrust Codes Limited: Using anti-counterfeit solutions and supply-chain traceability, Trust Codes® data-driven software connects brands to consumers with item level serialisation and world leading algorithms.DisclaimerLegal NoticeIn addition to the terms of the licence, this source code is provided by Trust Codes Limited, a New Zealand company, on an as-is basis, with no warranty expressed or implied. Neither Trust Codes Limited nor the contributors accept any liability for its use nor for any damages caused through its use. Trust Codes® is a registered trademark of Trust Codes Limited in New Zealand.All Rights Reserved.© Trust Codes Limited 2021.LicenseApache-2.0 License