Read binary into data buffer

Started by Joanna Carter, July 22, 2023, 07:09:18 PM

Previous topic - Next topic

Joanna Carter

I am using Swift to call Exiftool via a command line.

Anyone any ideas how to read in the return from a call that includes -b and returns binary data into a memory buffer in Swift?

Phil Harvey

Simple.  Run ExifTool using the -stay_open option and with stdout tied to stdin in both directions.

Write your command arguments to from Swift to stdout, ending with -execute1234 (or whatever number you want).

Read stdin until you see "ready{1234}\n" (or whatever number you used) at the end of the output.  The binary data is everything before this response string (if you used the -b option).

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).