dmtx / libdmtx

libdmtx Library
Other
297 stars 133 forks source link

Encoding GS1 Symbols #3

Closed blumf closed 6 years ago

blumf commented 7 years ago

How do you prepend the GS1 FNC1 data codepoint (232) to a datamatrix?

Doesn't seem to be any char value that translates to the FNC1 as a start data codepoint.

fpaquet commented 6 years ago

Still no solution ?

Encoding a GS1 FNC1 data codepoint (232) is needed to properly encode GS1 datastructes. Details: https://www.gs1.org/docs/barcodes/GS1_DataMatrix_Guideline.pdf

We need this feature too.

mungewell commented 6 years ago

If you just want to make a DataMatrix encoded with GS1, you could try this alternate project https://github.com/woo-j/zint

Their documentation says:

6.6.1 Data Matrix ECC200 (ISO 16022) ------------------------------------> Also known as Semacode this symbology was developed in 1989 by Acuity CiMatrix in partnership with the US DoD and NASA. The symbol can encode a large amount of data in a small area. Data Matrix ECC200 can encode characters in the Latin-1 set by default but also supports encoding using other character sets using the ECI mechanism. It can also encode GS1 data. The size of the generated symbol can also be adjusted using the --vers= option or by setting option_2 as shown in the table below. A separate symbology ID can be used to encode Health Industry Barcode (HIBC) data which adds a leading '+' character and a modulo-49 check digit to the encoded data. Note that only ECC200 encoding is supported, the older standards have now been removed from Zint.

It would be great if libDMTX could also do this function, the other project may be a good reference and a way to generate test barcode,

mungewell commented 6 years ago

Can confirm 'zint' project can encode GS1, who knows whether the forthcoming 13hr flight might prove fruitful :-)

xubuntu@xubuntu:~$ zint -o datamatrix.png -b 71 --border 10 --gs1 -d "[01]98898765432106[3202]012345[15]991231"
xubuntu@xubuntu:~$ dmtxread datamatrix.png 
0198898765432106320201234515991231
xubuntu@xubuntu:~$ dmtxread datamatrix.png -c
d:232
d:131
d:228
d:219
d:217
...
mungewell commented 6 years ago

Got something working, lets the user use '-G xx' parameter to dmtxread and dmtxwrite to specify which character represent FNC1. For example '-G 42' replaces '*' with FNC1.

Not quite ready for a pull request as only works/tested with ASCII encoding, but here's what I have: https://github.com/mungewell/libdmtx/tree/gs1-attempt1 https://github.com/mungewell/dmtx-utils/tree/gs1-attempt1

$ echo -n '*abc*123*456' | dmtxwrite -o test.png -G 42 -e a
$ ./dmtxread/dmtxread test.png -G 43
+abc+123+456
$ ./dmtxread/dmtxread test.png -c
d:232
d:098
d:099
d:100
d:232
d:142
d:052
d:232
d:175
d:055
d:129
p:147
e:173
...
fpaquet commented 6 years ago

Sounds good, i will give it a try next weekend...

mungewell commented 6 years ago

Everything should work as expected, however I'd like to clean up code before a Pull Request. I also need to tweak the wrappers for the addition API.

Let me know if you find any odd behavior.

fpaquet commented 6 years ago

Call to initialize encoder: int gs1 = '+'; g_debug("dmtxEncodeSetProp DmtxPropFnc1 %d", gs1); dmtxEncodeSetProp(enc, DmtxPropFnc1, gs1);

Used these decoders to verify gs1-datamatrix encoding with FNC1 prefix and embedded FNC1 symbols:

I've checked text- and c40-scheme.

All tests were SUCCESSFUL

Great work!

mungewell commented 6 years ago

Cleaned up code and issue pull request(s) https://github.com/dmtx/libdmtx/pull/10 https://github.com/dmtx/dmtx-utils/pull/4

Enjoy ;-)