Learn R Programming

gemini.R (version 0.17.2)

read_image: Read and encode image file as base64

Description

Reads an image file from the given path and encodes it as a base64 string. Used internally for Gemini API image upload.

Usage

read_image(img_path)

Value

Base64-encoded string of the image, or NULL if the file does not exist.

Arguments

img_path

Path to the image file.

Examples

Run this code
if (FALSE) {
base64_img <- read_image("cat.png")
}

Run the code above in your browser using DataLab