(Tutorial) Encode images, save to CSV (with decode capability)

Hi all,

This is an update to a previous “tutorial”, at this link:

Customize data scraping by editing xml.

In the attached workflow with two AutoHotkey scripts, you can see how to:

  1. Encode the image located at a URL in a CSV file to base64;
  2. Write the encoded data back to CSV;
  3. Verify that the encoding and decoding functions operate as intended, by decoding each base64 string back into an image, displaying it, and moving on to the next string-to-image process.

The best way to understand this is to review the attached workflow and AutoHotkey scripts.

A. The first AHK script, ‘AHKto64_11.ahk’, will download an image from the URL from each row of the first CSV, which is ‘AHKcsv.csv’. (This is building on the previous tutorial, where we extracted image URLs by editing XML). It will then encode that image. It sends the encoded string back to the workflow.

B. The workflow writes the encoded data into each row of ‘Encoded.csv’, in essence replacing the URL from ‘AHKcsv.csv’ in each row with base64 data, to be used for further processing. The workflow continues calling this AHK script until there are no more rows to process.

C. The workflow then runs the second AHK script, ‘base64decCheck.ahk’, which 1) extracts the base64 data from each row of ‘Encoded.csv’, 2) decodes the base64 data back into an image, and 3) shows the image for 250ms before sending control back to the workflow, which then processes the next row. This process repeats until there are no more encoded strings to process.

The intent here (imperfectly shown in the screen capture) is to create a pseudo-slideshow, demonstrating that encoding images to base64, and decoding base64 back to images, both work properly.

The workflow and two AHK scripts are attached below in a ZIP archive.


EncodeDecodeImages.zip (5.9 KB)