Manage images embedded in DOCX documents.

1. Usage

uniword images SUBCOMMAND FILE [OPTIONS]

2. Subcommands

Subcommand Description

list FILE

List all embedded images with metadata

extract FILE OUTPUT_DIR

Extract images to a directory

insert FILE IMAGE_PATH

Insert an image into the document

remove FILE IMAGE_NAME

Remove an image by filename

3. Options

3.1. list

--json

Output image metadata as JSON.

3.2. extract

--verbose, -v

Show names of extracted files.

3.3. insert

--output, -o (required)

Output file path.

--position

Paragraph index for insertion (appended at end by default).

--width

Image width string (e.g., 6in, 15cm, 400px).

--height

Image height string (e.g., 4in, 10cm).

--description

Alt text / accessibility description.

3.4. remove

--output, -o (required)

Output file path.

4. Examples

List images:

uniword images list document.docx
uniword images list document.docx --json

Extract all images:

uniword images extract document.docx ./output_images

Insert an image:

uniword images insert document.docx photo.png -o out.docx
uniword images insert document.docx logo.png -o out.docx --width 6in --height 4in
uniword images insert document.docx chart.png -o out.docx --position 2

Remove an image:

uniword images remove document.docx image1.png -o out.docx

5. Ruby API

doc = Uniword.load("document.docx")

# List
images = doc.list_images
images.each { |img| puts "#{img.name} (#{img.content_type})" }

# Extract
count = doc.extract_images("/tmp/images")

# Insert
doc.insert_image("photo.png", width: "6in", height: "4in")
    .save("output.docx")

# Remove
doc.remove_image("image1.png").save("output.docx")