https://github.com/psu-libraries/alt_text
AltText helps with accessibility by generating alt text for images.
https://github.com/psu-libraries/alt_text
ruby
Last synced: 4 months ago
JSON representation
AltText helps with accessibility by generating alt text for images.
- Host: GitHub
- URL: https://github.com/psu-libraries/alt_text
- Owner: psu-libraries
- License: mit
- Created: 2025-08-14T19:42:33.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-11-18T15:39:29.000Z (8 months ago)
- Last Synced: 2025-11-29T17:48:36.624Z (7 months ago)
- Topics: ruby
- Language: Ruby
- Homepage:
- Size: 84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## Alt Text Generator
This uses Ruby's AWS SDK to send images and a prompt to an LLM in Amazon's Bedrock to generate Alt Text for the images.
### Ruby Client Usage
This gem uses imagemagick to resize large images, so you will need to install imagemagick:
Mac:
```
brew install imagemagick
```
Ubuntu:
```
apt-get update
apt-get install imagemagick
```
Then, add the gem to your project:
In the Gemfile:
```
# Gemfile
gem 'alt_text'
```
```
bundle install
```
Or, via `gem install`:
```
gem install alt_text
```
Instantiate the client with injected AWS credentials:
```
client = AltText::Client.new {
access_key_id: ENV['YOUR_ACCESS_KEY_ID'],
secret_access_key: ENV['YOUR_SECRET_ACCESS_KEY'],
region: 'us-east-1'
}
```
Call the `#process_image` method with the image path, prompt, and LLM ID as arguments:
```
client.process_image('folder/image.png', 'Please generate alt text', 'sonnet3.51`)
```
*Note: A sample prompt can be found in `prompt.txt`.*
### CLI Usage
Copy the `.env.sample` file to `.env` and add your AWS credentials.
```
cp .env.sample .env
```
General CLI command to generate Alt Text for images in the `images/` directory:
```
bundle exec bin/alt_text \
-s output/output.txt \
-l default \
-d images \
-p prompt.txt
```
Run this for help:
```
bundle exec bin/alt_text -h
```