Up until I recently upgraded to macOS 13 (Ventura) I could run this Bash command to convert a JPEG image into a Base64 string in a script I occasionally use:
IMAGE_BASE64=$(base64 -b0 /path/to/image.jpg);
The resulting IMAGE_BASE64
value could be used as the variable $IMAGE_BASE64
in my script.
But I recently tried to use this script again in macOS 13 (Ventura) and this base64
command was failing with the following error:
base64: invalid argument -b0
Usage: base64 [-hDd] [-b num] [-i in_file] [-o out_file]
-h, --help display this message
-Dd, --decode decodes input
-b, --break break encoded string into num character lines
-i, --input input file (default: "-" for stdin)
-o, --output output file (default: "-" for stdout)
Switching the command to use -i
seems to solve the issue:
IMAGE_BASE64=$(base64 -i /path/to/image.jpg);
But what is the difference between the two commands?
What was -b0
doing previously prior to macOS 13 (Ventura) that -i
is handling now in macOS 13 (Ventura)?