Skip to main content

Images

Scanner Upload

Images must be taken by the scanner and feature:

  • The front of the item with the Serial number being visible
  • Enough Light. Users should be able to see the image on the screen and be able to re-take a photo before uploading (e.g. pressing scan button)

Image Specifications:

  • The image should be resized by the scanner to 1024px to 768px (or just 1024px width) or higher and submitted in jpeg format.
  • The Image should be serialized (Base64) and passed as a parameter to the GramChainInsertViaScanner API SerializedImage parameter which will hash the Base64 and store the image as a jpeg file named after it’s hash .
  • Once inserted Images can be retrieved as follows: ImageServer/Images/ImageHash.jpeg where:
    • ImageServer/ is the server address, e.g. https://GramChain-test.littlebit.sg/
    • Images/ is hardcoded string / folder
    • ImageHash is the image hash and can be found in API GetSingleLogFullDetails
    • .jpeg is the hardcoded string

Note that ImageServer will change once the system goes into production and it might be a different address from the API server as we might outsource image storage to a commercial service. Best practice is to use the prebuild ImageURL parameter from GetSingleLogFullDetails to abstract migration issues away.

Server Processing

Uploaded images will have a QR code added top right which links back to the GramChain explorer for a given parcel. This allows users to easily check a parcel status from a image. On the bottom right, we are adding a little GramChain watermark to reduce the likelihood of third parties copying the images.

GramChain Scanner

The SerializedImage variable will be hashed using SHA256 and the resulting hash will be used as the FileName for the image. The Hash is computed as follows:

       HashAlgorithm algorithm = SHA256.Create(); 
return algorithm.ComputeHash(Encoding.UTF8.GetBytes(inputString));

Resulting in sample hash file as follows:

  • 42738DC7FE2021A675C92F069F445B4A081A03C1A6FFE698BAF76F22490E4CB5.jpeg

The file will be saved as (where ~ is the server name, e.g. “https://GramChain.net/”)

  • ~/Images/42738DC7FE2021A675C92F069F445B4A081A03C1A6FFE698BAF76F22490E4CB5.jpeg

Utilitze ImageURL to get the image URL to load / display the image.