Description

This use case will show how to generate an image that contains another image using the ImageTemplateReceiver. For this example, the base image will be a check populated with synthetic data. The second image will be a barcode generated at a specified location on the check. 


NOTE: Please note that the same steps shown in this example can be used with other images to generate an image on another image using the ImageTemplateReceiver. 


IMPORTANT: Portions of this use case build off of another use case. The first use case shows how to generate check images filled with synthetically generated data. To see the first use case, you can click here.


In This Article


Step 1 - Create a Domain with Attributes

A Domain containing the Attributes for populating an image with synthetic data and/or images must be created. This Domain should contain all required Attributes for generating synthetic data on the base image. Click here to learn about the methods for importing and creating Domains.


For this example, a Check Domain has been created within a Project Version of a Project. It contains the following Attributes, which will be used to fill in the base check image with synthetic data: 


NOTE: A complete example can be viewed here - ImageTemplateReceiver: Generate a Check Image with Synthetic Data.


Step 2 - Create a barcode Attribute for the Image

An additional Attribute must be created to load the second image into memory and generate it on the base image when the Scenario is run. For this example, a barcode Attribute has been created. 




Step 3 - Assign and Configure the BlobTextGen Generator for the barcode Attribute

The BlobTextGen Generator must be assigned to the barcode Attribute created in Step 2 of this example. This Generator will read the file into memory as a blob (text or binary) from the user's local system. 


The following Generator parameters have been altered in this example: 

  • filePath - references the user's output directory path on their local computer. 
  • fileName - the name of the image file that will be generated on the base image (e.g., check). 
  • fileType - 'binary' has been selected to load the file path into memory. This should be chosen because it is an image and not text.  



Note: If the maxSize Attribute value is greater than the available heap size, the following warning will be displayed when the Scenario is run. 



Step 4 - Add the ImageTemplateReceiver to the Domain

The ImageTemplateReceiver will need to be added to the Domain. Click here to learn more about adding Receivers to Domains. 




Step 5 - Configure the ImageTemplateReciever Parameters for the Base Image

At a minimum, the user must enter the template (base image) name in the templateName parameter. For this example, an optional subdirectory titled 'images' has also been configured for the subDir parameter.  



Note: By default, the path for the template and output files is set to the user's output path, which is defined in GenRocket for the resource.output.directory Organization Resource.


Step 6 - Modify the Image Template and Upload the Base Image

Upload the base image (e.g., check) to the Image Template by completing these steps: 

  • Within the Domain Dashboard, select the ImageTemplateReceiver.



  • Next, click on Manage Image Template at the bottom of the ImageTemplateReceiver parameters.



  • Click on the Upload Image button to upload the template image that will be augmented.




  • Click on Choose File to browse for and select the template image.



  • Click the Save button.



  • The uploaded image will be displayed within the ImageTemplateReceiver Management Dashboard.




Step 7 - Position Required Synthetic Test Data Attributes on the Base Image

Position Attributes for synthetic test data generation accordingly on the base image. This can be done by completing these steps: 

  1. Select an Attribute on the left side of the screen.
  2. Click and drag on the image to position the Attribute. 
  3. Once finished, click the Save (Disk) icon for the Attribute. 
  4. Repeat the above steps for each Attribute that needs to be positioned on the image.



NOTE: Click here for a complete example using the above check image. 


Step 8 - Add the barcode Attribute to the ImageTemplateReceiver Template

  • Select the barcode Attribute within the Domain Attributes. It will be highlighted in blue.



  • Click on the base image and drag to position the barcode Attribute where it will be generated. This step positions where the image will be on the base image. The actual image is pulled in at the time of test data generation.



  • Then click on the Save (disk) icon to save the change.


  • OPTIONAL: Preview the image. Please note that the value shown for the barcode Attribute will be whatever has been entered in the exampleValue parameter for the BlobTextGen Generator.


    This is because the barcode image is loaded into memory and generated on the check when the Scenario is run. It is not loaded and stored as done with the base image (e.g., check).



  • Click on the Return to Dashboard button to return to the Receiver Dashboard.



Step 9 - Modify the dataType Attribute Property Key for the barcode Attribute

The "blob" data type must be selected for the barcode Attribute within the Receiver Attribute Property Keys. This can be done by completing these steps: 

  • In the Receiver Dashboard, select the barcode Attribute.



  • For the dataType property key, select 'Blob.' Then click the Save button.


Step 10 - Create a Scenario for the Domain 

For this example, a Scenario titled 'CheckScenario' has been created. Click here to learn more about creating Scenarios. 



Step 11 - Download the Required Components and Generate Test Data

The user will need to download each component needed to generate their data manually (e.g., Scenario, Scenario Chain, G-Case, Configuration Files, etc.) 


IMPORTANT: Please note that downloading Scenarios, Scenario Chains, G-Cases, etc., is optional for users who have set up G-Repository Client on their local machine.

For this example, only a Scenario is used to generate a single check image with a barcode. These steps will need to be completed: 

  • Download the Scenario to the user's local machine.


  • Ensure the base image file (e.g., check) is located where defined in the ImageTemplateReceiver path parameter.


  • Ensure the secondary image file (e.g., barcode) is defined in the BlobTextGen Generator filePath parameter. 


  • Open a Command prompt or Terminal and enter the following command with the Scenario file name. 
    genrocket -r <ScenarioName.grs>


    Example: 

    genrocket -r CheckScenario.grs

    NOTE: The command will vary depending on the components used to generate test data. For example, when using G-Cases with a Scenario, Scenario Chain, or Scenario Chain Set, the command will have additional information for the G-Case. 


Sample Output

The following check was generated in this example: