Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Converter ¶
type Converter struct { NumThread int QRChunkSize int64 QRSideLength int FilenamePadLength int FilePrefix string }
Converter is the instance of this converter. You can directly manipulate the available parameters to modify settings.
func New ¶
func New() *Converter
New creates a converter instance with default settings.
Example ¶
converter := New() fmt.Println("Default threads:", converter.NumThread) converter.NumThread = 10 fmt.Println("Modified threads:", converter.NumThread)
Output: Default threads: 25 Modified threads: 10
func (*Converter) Decode ¶
Decode reads qr codes from a source folder, decodes them and writes the result in the destination file. The source folder should only contain images that belong to one file. It writes the current progress percentage into the provided progress reference integer.
Example ¶
converter := New() progress := 0 tempFolder := testDataRoot + osSep + "ExampleDecode" tempOutput := testDataRoot + osSep + "ExampleDecode.txt" // First encode as in the example for Encode converter.Encode(testFile, tempFolder, &progress) // Then decode progress = 0 err := converter.Decode(tempFolder, tempOutput, &progress) os.RemoveAll(tempFolder) // Hash file hasher := sha256.New() f, err2 := os.Open(tempOutput) _, err3 := io.Copy(hasher, f) f.Close() os.RemoveAll(tempOutput) fmt.Println("Decoded with errors", err, err2, err3, "into file with checksum", hex.EncodeToString(hasher.Sum(nil)), "and final progress", progress)
Output: Decoded with errors <nil> <nil> <nil> into file with checksum 603fc453b56a70b93befaaeca656a2045968d9ee74cdc7a98f3b41e3b3017169 and final progress 100
func (*Converter) Encode ¶
Encode reads the input file and converts it to QR code images in the destination folder. It writes the current progress percentage into the provided progress reference integer.
Example ¶
converter := New() progress := 0 tempFolder := testDataRoot + osSep + "ExampleEncode" err := converter.Encode(testFile, tempFolder, &progress) files, err2 := ioutil.ReadDir(tempFolder) os.RemoveAll(tempFolder) fmt.Println("Encoded with errors", err, err2, "into", len(files), "frames with final progress", progress)
Output: Encoded with errors <nil> <nil> into 382 frames with final progress 100
Click to show internal directories.
Click to hide internal directories.