Go Image Processor is a command-line tool for performing various image processing operations on JPEG images.
- Resize images
- Denoise images
- Rotate images
- Binarize images using Otsu's method
- Concatenate images vertically or horizontally
- Generate test images
- Detect edges using Sobel operator
- Configuration file for default settings
- Graphical User Interface for easier use
-
Ensure you have Go installed on your system (version 1.16 or later).
-
Clone this repository
git clone https://github.com/okamyuji/go-image-processor.git
-
Navigate to the project directory
cd go-image-processor
-
Build the project
make all
The general syntax for using the CLI tool is:
./go-image-processor <command> [arguments]
A simple graphical user interface (GUI) is available for easier use of the image processing tool. To build and run the GUI:
make build-gui
make run-gui
The GUI provides a user-friendly interface for selecting operations, inputting file paths, and setting parameters for image processing tasks.
-
Resize an image
./go-image-processor resize <input> <output> -width <width> -height <height>
-
Denoise an image
./go-image-processor denoise <input> <output>
-
Rotate an image
./go-image-processor rotate <input> <output> -angle <angle>
-
Binarize an image
./go-image-processor binarize <input> <output>
-
Concatenate images vertically
./go-image-processor concatvert <output> <input1> <input2> [input3...]
-
Concatenate images horizontally
./go-image-processor concathorz <output> <input1> <input2> [input3...]
-
Generate a test image
./go-image-processor generatetest <output> -width <width> -height <height>
-
Detect edges in an image:
./go-image-processor edges <input> <output>
For more information about a specific command, use
./go-image-processor <command> -h
-
Resize an image to 800x600:
./go-image-processor resize input.jpg output.jpg -width 800 -height 600
-
Rotate an image by 90 degrees:
./go-image-processor rotate input.jpg output.jpg -angle 90
-
Concatenate three images vertically:
./go-image-processor concatvert output.jpg input1.jpg input2.jpg input3.jpg
-
Detect edges in an image:
./go-image-processor edges input.jpg output_edges.jpg
The application uses a config.yaml
file for default settings. You can modify this file to change the default values for various operations. The configuration file should be placed in the root directory of the project.
Example config.yaml
:
default_width: 800
default_height: 600
default_angle: 90
jpeg_quality: 75
If the configuration file is not found, the application will use built-in default values.
This project includes a Makefile for easy building, testing, and running example commands.
-
Build the project
make build
-
Run tests:
make test
-
Clean build artifacts
make clean
-
Run example commands:
make resize-example make denoise-example make rotate-example make binarize-example make concatvert-example make concathorz-example make generatetest-example
-
Run benchmarks:
make benchmark
These commands will process the example images in the examples
directory.
This project uses GitHub Actions for continuous integration. On every push and pull request to the main branch, the project is built and all tests are run automatically.
To run benchmarks for the image processing functions, use
make benchmark
This will run performance tests on all the main functions, giving you an idea of their execution time and efficiency.
The code is documented using godoc. To view the documentation, run
godoc -http=:6060
Then open your browser and navigate to http://localhost:6060/pkg/github.com/okamyuji/go-image-processor/pkg/processor/
The application uses Go's built-in logging package to log information about the operations being performed. Logs are printed to stderr by default.
To redirect logs to a file, you can run the application like this:
./go-image-processor <command> [arguments] 2> logfile.txt
This will send all log output to logfile.txt
.
Have you ever needed to make a photo smaller or bigger? That's what our resize feature does!
- It takes your original image
- Keeps the same shape (like a rectangle stays a rectangle)
- Makes it bigger or smaller while keeping everything looking natural
- Saves the new sized image
Example: Making a large 1000x1000 photo smaller to fit on your screen at 500x500.
Think of noise as tiny unwanted dots in your photo, like static on an old TV.
- The program looks at each part of the image
- For each spot, it checks the colors around it
- If it finds a dot that looks out of place, it smooths it out
- The result is a cleaner, clearer image
Example: Making a grainy dark photo look smoother and clearer.
Just like turning a photo in your hands, this feature rotates your image.
- You tell it how many degrees to turn (like 90° for a quarter turn)
- It carefully moves each part of the image to its new position
- Makes sure nothing gets cut off
- Saves the turned image
Example: Turning a sideways photo to make it upright.
This turns your image into just black and white - no gray areas!
- Looks at how bright each part of the image is
- Decides if each spot should be black or white
- Uses a smart method (called Otsu) to make the best choice
- Creates a clear black and white version
Example: Making a color photo look like an old newspaper picture.
This feature can join images together like puzzle pieces!
Vertical Concatenation:
- Takes two or more images
- Stacks them on top of each other
- Makes sure they line up perfectly
- Creates one tall image
Horizontal Concatenation:
- Takes two or more images
- Places them side by side
- Lines them up evenly
- Creates one wide image
Example: Joining two holiday photos to make a panorama.
This feature finds and highlights the outlines in your image!
- Looks for places where colors change suddenly
- Marks these changes as edges
- Makes the edges stand out
- Creates an image showing just the outlines
Example: Making a sketch-like version of a photo, showing just the main shapes.
This feature automatically detects and corrects tilted images!
- Analyzes the image to find strong lines or text
- Calculates how much the image is tilted
- Rotates the image to make it straight
- Saves the corrected image
Example: Fixing a scanned document that was placed slightly crooked.
Need sample images to practice with? This feature creates them!
- Makes different types of test images
- Creates patterns that are perfect for testing
- Lets you choose the size
- Saves them as regular image files
Example: Creating a checkerboard pattern to test image processing.
Remember: All these features keep your original image safe and create new files with the changes. It's like having a photo copy machine that can do magic tricks with your pictures! 🪄📸
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.