## bar code for golden book / cd?

Records, publishing, shop etc.
ravanwin
Posts: 5060
Joined: Thu Aug 26, 2004 8:08 pm
Location: edinburgh
Contact:

### bar code for golden book / cd?

can we make a barcode for the golden hour book?

anyone?

ryan

swithun
Posts: 2683
Joined: Wed Mar 29, 2006 12:24 pm
Give me the ISBN and I'll give you the barcode. I wrote a program which would generate bar codes from 12 digit numbers - 2 DDMMYY birthdays for example.

Barcodes are fascinating. For most products, there is a country code, an organisation code and a product code. Countries can use a range of numbers. Organisations are given a code, and they can allocate their own product codes. The last digit is a checksum to ensure that the code is read correctly. Companies which make lots of products have short organisation codes.

There are 3 different ways to represent each number in the code - A, B and C. A and B are used for the numbers 2 to7. The combination of bars from A and B encodes the first digit, which doesn't have any bars associated with it. The C series is used for the last 6 digits. I can't remember the sum for the last digit, but it is something like the sum of the odd (1st, 3rd etc) numbers multiplied by 3 plus the sum of the even (2nd, 4th etc) modulus 10.

For ISBN numbers, they all start with 978, so that leaves 9 digits for the rest.

ravanwin
Posts: 5060
Joined: Thu Aug 26, 2004 8:08 pm
Location: edinburgh
Contact:
s-dawg, your new avatar should be a bar code.#
r

swithun
Posts: 2683
Joined: Wed Mar 29, 2006 12:24 pm
Here is the Fortran program I wrote for generating the barcode. You can compile it with the command

Code: Select all

`f77    barcode.f   -o barcode`
and run it in a pipeline with some other programs for scaling up the PBM and converting it to PNG format like

Code: Select all

`echo "1 2 3 4 5 6 7 8 9 0 1 2" | ./barcode | pnmscale 4 | pnmtopng > barcode.png`

Code: Select all

`cc output PBM format image of barcodec      program barcode      integer data_file      integer i, j, k, p, height, width      integer checksum      integer given(13), parity(0:9, 2:7), codes(3, 0:9, 7)      parameter (data_file = 10)      parameter (height = 20, width = 97)cc read in parity and codes from data filec      open (data_file, FILE="barcode_data.dat", STATUS="OLD")      do i = 0, 9        read (data_file, 910) (parity(i, j), j = 2, 7)      enddo      do i = 1, 3        do j = 0, 9          read (data_file, 920) (codes(i, j, k), k = 1, 7)        enddo      enddo      close (data_file)cc read in given numbers and calculate checksumc      read (*,*) (given(i), i = 1, 12)      given(13) = checksum(given)cc outputc      write (*, 940) "P1"      write (*, 950) width, height + 2c top line of white      do i = 1, width        write (*, 960) 0      enddo      do k = 1, heightc left guard bars        write (*, 940) "0 1 0 1"        do i = 2, 7          p = parity(given(1), i)          write (*, 920) (codes(p, given(i), j), j = 1, 7)        enddoc centre guard bars        write (*, 940) "0 1 0 1 0"        do i = 8, 13          write (*, 920) (codes(3, given(i), j), j = 1, 7)        enddoc right guard bars        write (*, 940) "1 0 1 0"      enddoc bottom line of white      do i = 1, width        write (*, 960) 0      enddocc formatsc 910  format (6I2) 920  format (7I2) 940  format (A) 950  format (2I3) 960  format (I2)      stop      endcc calculate and return checksum from given digitsc      integer function checksum(given)      integer i, total, given(12)      total = 0      do i = 1, 12        total = total + given(i)        if (0 == MOD(i, 2)) then          total = total + (2 * given(i))        endif      enddo      checksum = MOD(10 - MOD(total, 10), 10)      return      end`

The data file barcode_data.dat is:

Code: Select all

`1 1 1 1 1 1 1 1 2 1 2 2 1 1 2 2 1 2 1 1 2 2 2 1 1 2 1 1 2 2 1 2 2 1 1 2 1 2 2 2 1 1 1 2 1 2 1 2 1 2 1 2 2 1 1 2 2 1 2 1 0 0 0 1 1 0 10 0 1 1 0 0 10 0 1 0 0 1 10 1 1 1 1 0 10 1 0 0 0 1 10 1 1 0 0 0 10 1 0 1 1 1 10 1 1 1 0 1 10 1 1 0 1 1 10 0 0 1 0 1 10 1 0 0 1 1 1 0 1 1 0 0 1 1 0 0 1 1 0 1 1 0 1 0 0 0 0 1 0 0 1 1 1 0 1 0 1 1 1 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 0 1 0 1 1 1 1 1 1 0 0 1 0 1 1 0 0 1 1 0 1 1 0 1 1 0 0 1 0 0 0 0 1 0 1 0 1 1 1 0 0 1 0 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 1 1 1 0 1 0 0`