README.md
May 4, 2026 · View on GitHub
ForImage: A Fortran library for processing and editing PNM images and managing colors.
- PNM File Support
- Color Support
- fpm dependency
- How to run demos
- Projects Utilizing ForImage
- API documentation
- Contributing
- References
PNM File Support
ForImage offers comprehensive support for PNM files, including creation, importing, and exporting capabilities. It seamlessly handles formats such as PBM, PGM, and PPM in both ASCII and binary representations.
Available features include:
- Original
- Negative
- Brighten
- Swap Channels
- Remove Channels
- Greyscale
- Rotate
- Flip Horizontal
- Flip Vertical
- Crop
- Resize
Color Support
ForImage supports different color representations like RGB, CMYK, Decimal, Hexadecimal, HSV, HSL, XYZ, and color names. Users can easily set and retrieve color values, switch between color types, and find the closest matching colors.














fpm dependency
If you want to use ForImage as a dependency in your own fpm project,
you can easily include it by adding the following line to your fpm.toml file:
[dependencies]
forimage = {git="https://github.com/gha3mi/forimage.git"}
How to run demos
The demo_ppm program demonstrates various operations on PPM (Portable Pixmap) images. It generates Mandelbrot fractals, performs diverse manipulations, and exports images in the PPM format.
The demo_color program showcases manipulation of color spaces and their conversions. This program sets a custom color using various methods, converts it to different color spaces, retrieves color values, finds the nearest color, and prints color details.
To get started, follow these steps:
Clone the repository:
Clone the ForImage repository from GitHub using the following command:
git clone https://github.com/gha3mi/forimage.git
Navigate to the cloned directory:
cd forimage
Using fpm
Run the demo_ppm example:
fpm run --example demo_ppm
Run the demo_color example:
fpm run --example demo_color
Using CMake
cmake -B build -D BUILD_FORIMAGE_EXAMPLES=on
cmake --build build
Run the demo_ppm example:
./build/example/demo_ppm
Run the demo_color example:
./build/example/demo_color
Note: The executable must be run from the forimage directory.
Status
| OS | Compiler | Version | fpm | cmake |
|---|---|---|---|---|
| ubuntu 24.04 | flang-new | 22.1.4 | 0.13.0 ✅ | 4.3.2 ✅ |
| ubuntu 24.04 | gfortran | 15.2.0 | 0.13.0 ✅ | 4.3.2 ✅ |
| ubuntu 24.04 | ifx | 2026.0.0 | 0.13.0 ✅ | 4.3.2 ✅ |
| ubuntu 24.04 | nvfortran | 26.3 | 0.13.0 ✅ | 4.3.2 ✅ |
| macos 15 | gfortran | 15.2.0 | 0.13.0 ✅ | 4.3.2 ✅ |
| windows 2025 | gfortran | 15.2.0 | 0.13.0 ✅ | 4.3.2 ✅ |
| windows 2025 | ifx | 2026.0.0 | 0.12.0 ✅ | 4.3.2 ✅ |
Projects Utilizing ForImage
- ForColormap: A Fortran library for colormaps
- ForCAD: A Fortran library for Geometric Modeling using NURBS
If your project utilizes ForImage and you want to be added to this list, please add your project and create a pull request.
API documentation
The most up-to-date API documentation for the master branch is available
here.
To generate the API documentation for ForImage using
ford run the following
command:
ford README.md
Contributing
Contributions to ForImage are welcome!
If you find any issues or would like to suggest improvements, please open an issue.