This project is a multithreaded script written in Go that retrieves JPG images from Amazon S3 and optimizes them by reducing their size to a desired dimension. It aims to automate the process of optimizing images on a large scale.
The project consists of the following files and directories:
main.go
: The entry point of the program that initiates the image processing.s3/
: A package that encapsulates the communication with Amazon S3.processor/
: A package that handles image processing.utils/
: A package containing utility functions.
-
Language: Go (Golang)
-
Libraries:
github.com/aws/aws-sdk-go v1.44.271
: The official AWS SDK for Go, used for interacting with Amazon S3.github.com/disintegration/imaging v1.6.2
: A powerful imaging library for Go, used for image resizing and optimization.github.com/jmespath/go-jmespath v0.4.0
: A Go implementation of JMESPath, used for querying JSON data.github.com/joho/godotenv v1.5.1
: A Go library for loading environment variables from a.env
file.
To run the project, follow these steps:
-
Clone the repository:
git clone https://github.com/EduardoPedrosa/image-optimization.git
-
Navigate to the project directory:
cd image-optimization
-
Create a
.env
file and set the required environment variables (e.g., AWS access key, secret key, region, S3 bucket, etc.). -
Build and run the project using the following command:
go run main.go
Note: Make sure you have Go installed and configured on your machine.
To test the project, run this command:
go test ./... -cover