diff --git a/.gitignore b/.gitignore index 45c0b22..48cf7d7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,7 @@ nimcache !tests/image.jpg tests/t* !tests/t*.nim +examples/* +!examples/*.nim +!examples/*.nims +!examples/sample.png diff --git a/README.md b/README.md index 115e963..79c0cda 100644 --- a/README.md +++ b/README.md @@ -59,3 +59,6 @@ To have some boilerplate for recreative programming with images. - [x] Vertically, Horizontally - [ ] Radial - Documentation + +## Examples +See [examples](./examples) directory. diff --git a/examples/config.nims b/examples/config.nims new file mode 100644 index 0000000..80091ff --- /dev/null +++ b/examples/config.nims @@ -0,0 +1 @@ +switch("path", "$projectDir/../src") diff --git a/examples/flip.nim b/examples/flip.nim new file mode 100644 index 0000000..60c9d71 --- /dev/null +++ b/examples/flip.nim @@ -0,0 +1,11 @@ +import imageman + +let img = loadImage[ColorRGBU]("sample.png") + +block: + let img2 = img.flippedHoriz() + img2.savePNG("out_flip_horiz.png") + +block: + let img2 = img.flippedVert() + img2.savePNG("out_flip_vert.png") diff --git a/examples/resize.nim b/examples/resize.nim new file mode 100644 index 0000000..1f301dd --- /dev/null +++ b/examples/resize.nim @@ -0,0 +1,5 @@ +import imageman + +let img = loadImage[ColorRGBU]("sample.png") +let img2 = img.resizedBicubic(512, 512) +img2.savePNG("out_resize_bicubic.png") diff --git a/examples/sample.png b/examples/sample.png new file mode 100644 index 0000000..1bceb6d Binary files /dev/null and b/examples/sample.png differ diff --git a/imageman.nimble b/imageman.nimble index e119964..f952220 100644 --- a/imageman.nimble +++ b/imageman.nimble @@ -10,3 +10,10 @@ srcDir = "src" requires "nim >= 0.20.0" requires "stb_image >= 2.2" + +task examples, "Run examples": + withDir "examples": + let srcs = ["resize.nim", "flip.nim"] + for src in srcs: + echo "Run: " & src & " example" + exec "nim c -r --hints:off --verbosity:0 " & src