Skip to content

Repository files navigation

Cosmo Image Metadata Tool

Cosmo is a command-line tool for managing and updating image metadata in bulk. It offers functionality to rename images sequentially and update metadata based on a CSV file input. This project leverages ExifTool to handle metadata extraction and updating.

Table of Contents


Features

  • Bulk Metadata Update: Update image metadata (e.g., title, keywords, copyright status) based on a CSV file.
  • Sequential Image Renaming: Rename images in a specified directory and export the results to a CSV file.
  • Combined Processing: Run both renaming and metadata updates with a single command.

Requirements

This project requires ExifTool to be installed on your system.

Installing ExifTool

  • On macOS: Use Homebrew
  brew install exiftool
  • On Ubuntu/Debian: Use APT
  sudo apt-get update
  sudo apt-get install -y exiftool
  • On Windows: Download and install ExifTool from the official website.

  • Chocolatey for windows:

   choco install exiftool

Installation

go version: 1.23

Install with go install (make sure you've installed go):

   go isntall https://github.com/Roisfaozi/cosmo.git
   cd cosmo

Or use this soure code

  1. Clone the repository:

    git clone https://github.com/Roisfaozi/cosmo.git
    cd cosmo
  2. Install the required dependencies:

    go get ./...
  3. Build the project:

    go build -o cosmo ./cmd/main.go

Usage

Rename Command

The rename command renames all images in a specified directory sequentially and exports the renaming information to a CSV file.

Command Syntax
cosmo rename [directory] --ext=[file extension]
Example
cosmo rename ./testdata --ext=".jpg"

This command renames all .jpg images in the ./testdata directory and saves the renaming details in renamed_files.csv within the same directory.

Update Metadata Command

The update-metadata command updates the metadata of all images in a specified directory based on a CSV file.

Command Syntax
cosmo update-metadata [csv-file]
Example
cosmo update-metadata ./testdata/metadata.csv

The CSV file should have the following columns:

  • SourceFile: Path to the image file
  • ObjectName: Title or name of the object in the image
  • Keywords: Keywords associated with the image
  • CopyrightStatus: Copyright status of the image
  • Marked: Marked status (e.g., TRUE or FALSE)
  • CopyrightNotice: Copyright notice information

Process Command

The process command combines the functionality of both the rename and update-metadata commands.

Command Syntax
cosmo process [directory] --ext=[file extension]
Example
cosmo process ./testdata --ext=".jpg"

This command renames all .jpg images in the ./testdata directory and updates the metadata based on the metadata.csv file.

Testing

To run the tests, run the following command:

go test ./...

For verbose output:

go test -v ./...

To run specific tests, use the -run flag:

go test -v -run=TestUpdateMetadata  ./...

This project uses testify for assertions and exiftool for metadata handling.

Contributing

If you would like to contribute to this project, please open an issue or submit a pull request. Thank you!

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Commit your changes and push your branch.
  4. Open a pull request describing your changes.

License

This project is licensed under the MIT License.

Contact for Project

Email: roisfaozi8@gmail.com

Website: roisfaozi.com

Support this project

If you find this project useful, please consider supporting it by making a donation.

PayPal Button

About

Cosmo is a command-line tool for managing and updating image metadata in bulk. It offers functionality to rename images sequentially and update metadata based on a CSV file input. This project leverages ExifTool to handle metadata extraction and updating.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages