Compare commits

..

10 Commits

Author SHA1 Message Date
Murat 9b01bcce2d Fix formatting in README for build instructions 2026-01-31 19:07:23 +03:00
murat f3c10b807d chore: update .gitignore for windows build files 2026-01-31 19:03:27 +03:00
murat adc81e0a0a docs: add initial README 2026-01-31 18:40:57 +03:00
murat e35c4043bf removed compile.sh shell script 2026-01-31 18:35:08 +03:00
murat 071eb7b61d chore: add .gitignore for build artifacts 2026-01-31 18:33:41 +03:00
murat 8a675f15dd add cmake build system 2026-01-31 18:33:41 +03:00
Murat 74e93cc050 Add MIT License to the project 2026-01-31 18:24:50 +03:00
murat e7725e6e24 docs: acknowledge stb_image as third-party dependency 2026-01-31 18:21:08 +03:00
murat e72c4db0ca feature: add proper --help output 2026-01-31 18:19:04 +03:00
murat 19e7524809 beautify terminal output 2026-01-31 18:06:37 +03:00
7 changed files with 106 additions and 9 deletions
+18
View File
@@ -0,0 +1,18 @@
# Build directories
build/
build-win/
cmake-build-*/
# CMake files
CMakeFiles/
CMakeCache.txt
Makefile
cmake_install.cmake
# Binaries
main
ccolors
ccolor.exe
# JSON output
palette.json
+7
View File
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.10)
project(ccolors)
set(CMAKE_CXX_STANDARD 17)
add_executable(ccolors main.cpp)
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 muwat0
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+36
View File
@@ -0,0 +1,36 @@
# ccolors
Small CLI tool to extract dominant color palettes from images.
## Features
- JPEG / PNG support
- Terminal color preview
- HEX output
- JSON export
- No external dependencies
## Build
### Linux / macOS
```bash
mkdir build
cd build
cmake ..
make
```
## Usage
```bash
./ccolors image.jpg
```
## Output
- Prints color swatches + hex
- Writes palette.json
## Dependencies
- stb_image.h (included)
## License
MIT
+6
View File
@@ -0,0 +1,6 @@
This project uses stb_image.h by Sean Barrett.
stb_image.h is licensed under the MIT license or placed in the public domain.
Source:
https://github.com/nothings/stb
-2
View File
@@ -1,2 +0,0 @@
#!/usr/bin/bash
g++ -std=c++17 main.cpp -O2 -o main
+18 -7
View File
@@ -30,18 +30,26 @@ int main(int argc, char *argv[]) {
for (int i = 0; i <= argc - 1; i++) {
std::string arg = argv[i];
if (arg == "--help" || arg == "-h") {
cout << "help flag detected!";
cout <<
"ccolors - extract color palette from images\n\n"
"Usage:\n"
" " << argv[0] << " <image>\n\n"
"Options:\n"
" -h, --help Show this help page\n\n"
"Output:\n"
" Prints dominant colors as HEX and terminal swatches\n"
" Also writes palette.json\n";
return 0;
}
}
if (argc != 2) {
cout << "Please specify image file. " << argv[0] << " imagefile.jpg";
cout << "Please specify a image file. " << argv[0] << " imagefile.jpg"
<< "\nTry \"" << argv[0] << " --help\" for more information.";
return 1;
}
std::string imagefile = argv[1];
cout << "File: " << imagefile << "\n";
if (!fs::is_regular_file(imagefile)) {
std::cout << "File not found: " << imagefile << "\n";
@@ -58,11 +66,11 @@ int main(int argc, char *argv[]) {
file.read(reinterpret_cast<char*>(header), 8);
if (is_png(header)) {
cout << "PNG detected\n";
cout << "PNG file detected!\n";
} else if (is_jpeg(header)) {
cout << "JPEG detected\n";
cout << "JPEG file detected!\n";
} else {
cout << "Unkown format!\n";
cout << "Unkown image file format!\n";
return 1;
}
@@ -77,14 +85,17 @@ int main(int argc, char *argv[]) {
);
if (!data) {
cout << "Failed to load image\n";
cout << "Failed to load image!\n";
return 1;
}
cout << "**********\n";
cout << "Loaded image:\n";
cout << "Width: " << width << "\n";
cout << "Height: " << height << "\n";
cout << "Channels: " << channels << "\n";
cout << "**********\n";
std::vector<Pixel> samples;