Rust program which will help generating image descriptions for WordPress image uploads
Find a file
2024-11-18 23:39:10 +01:00
src added hint to .env file when calling the program 2024-11-18 23:39:10 +01:00
.env.example first properly working Version 2024-11-18 22:50:48 +01:00
.gitignore ignoring dotenv 2024-11-18 21:11:43 +01:00
Cargo.toml fixing Cargo edition 2024-11-18 23:10:36 +01:00
LICENSE.md Adding License 2024-11-18 23:09:06 +01:00
README.md added hint to .env file when calling the program 2024-11-18 23:39:10 +01:00

Description

I wanted to write a tool in Rust which takes an Image as command line argument and then sends this image to ChatGPT to generate an image description. Once it has received the image description it uploads the image to a WordPress media library as new image. After the upload it will add the image description received via ChatGPT as the ALT text and description of the uploaded image in the WordPress media library.

The script will take the URL of the Wordpress site, the username and application password for Wordpress as well as the OpenAPI URL, ChatGPT model and OpenAPI API key as configuration parameters from a .env file.

preparation

Install Rust on your machine. Copy the .env.example to .env

testing

cargo run -- /path/to/your/image.jpg

compilation

cargo build --release

will build the binary in ./target/release/image-helper-wordpress

running

 $image-helper-wordpress: ./target/release/image-helper-wordpress /Users/username/Pictures/DJI_0247.jpg
Generated description: Aerial view of a circular lake surrounded by dense forest, with a small cluster of houses lining one edge. A second smaller lake is visible in the background, also encircled by forest.
Successfully uploaded image to WordPress with description
Image URL: https://example.wordpress.com/wp-content/uploads/2024/11/DJI_0247-scaled.jpg

Hint: make sure that the .env file is located in $PWD when calling the script