A command-line interface (CLI) that will take in a bitmap file (as a path on-disk), execute some color and/or raster transforms, and write the result to an output file.
Accept three parameters on the command line.
Transform an input image file, using input parameters, and write resulting transform file to the local file system.
Exception handling will ensure application continues or exits gracefully in case of bad or missing parameters, or bugs in the code that cause a failure in a transform.
Supports PNG file format only.
- Develop small, nested methods that perform specific activities (modularization)
- Main should call helper methods to perform the work
- Document all methods
- Contain a Bitmap Class that is instantiated when a BMP file is read
- Three arguments are required to execute the Transform function
- Three transforms must be available as instance methods within the Bitmap Class
- CLI should return useful Error messages if used incorrectly
- CLI should log a success message upon completion
This is a command-line application that needs to be built into an executable file before running.
- Path to a local bitmap file of type ".bmp"
- Gradle 7.4.2 or newer
- JVM: Java Eclipse Adoptium v17+
- OpenJDK: Temurin 17+
Gradle:
- Clone to your local.
- Build:
./gradlew build
- Test:
./gradlew test
- Run:
./gradlew run --args "infile outfile transform"
Note: If you omit --args
and everything after it, the app will return basic usage instructions.
Real Life using IntelliJ IDEA and Terminal:
- Configure Build Artifacts output to a folder that makes sense to you for example:
./project-root/build-output
. - Pick your output file type:
JAR
. - Configure Build to point to
bitmap-transformer.app.main
. - Select build target
bitmap-transformer [app:build]
. - Review the MANIFEST.MF to ensure it points to your intended Main class.
- Click Build and review the output. It should show
bitmap-transformer.app.main
and its output file location. - In the terminal, change directory to the build output folder or copy
bitmap-transfomer-jar
to a useful location. - In the terminal run
> java -jar bitmap-transformer-jar
and you should get helpful output from the App.
For detailed steps on the many ways to build and execute a Java application, check out writeup on the subject on baeldung dot com
Steps 7 and 8 can be run in a shell environment, so long as the Java SDK is in the path or environment variables.
Review 'META-INF' and '.idea/misc.xml' for this project's default build metadata.
Infile: This should point to an existing PNG file at the working directory.
Outfile: This should be the output filename of type PNG in the format 'filename.png'.
Transform: There are three:
- bars: Adds jail bars to the image.
- rotate: Rotates the image by 90 degrees clockwise.
- mirror: Flip the image along the vertical axis.
- Use JUnit
- Define descriptive tests
- Ensure valid inputs are handled correctly
- Ensure invalid inputs are handled correctly
- Gather user input (infile, outfile, transform)
- Read input bitmap file
- Parse bitmap data into Bitmap object (instance of Bitmap class)
- Use data from parsed Bitmap to execute transform on data directly
- Write the mutated image data to an output file with the specified name
- Invert
- Randomize
- Black and White
- Darken or Lighten
- Add or Multiply a Hue
- Add or Subtract a Contrast
- Pixelate
- Add border
- Add watermark
- Rotate
- Vertical/horizontal mirror
- Vertical/horizontal stretch
Rotate transformation method code inspired by StackOverflow question "Rotate 90 degree to right image in java"
Flip transformation method code inspired by StackOverflow question "Flip Image with Graphics2D"
IntelliJ IDEA Help Compiling Applications
Build and execute advice at baeldung dot com
Regex help from regex 101 dot com