Script Kit Logo
Script Kit
by John Lindquist
Vercel OSS Program

Scripts by ffael

Img to Base64 Markdown

ffael's avatar
Rafael Ferreira
// Name: Img to Base64 Markdown
// Description: Convert image to Base64 Markdown and save to journal.
// Author: ffael
import '@johnlindquist/kit'
// Get selected file path or prompt user to select an image file
let imagePath: string = await getSelectedFile()
if (!imagePath) { imagePath = await selectFile(`Choose an image:`)
}
if (!imagePath) {
// Exit if no image path is selected by the user
exit()
}
const extension: string = path.extname(imagePath)
const allowImageExtensions: string[] = ['.png', '.jpg', '.jpeg', '.gif']
// Validate if the selected file is a supported image type
66 lines below • View full script