theotherphil / imagecli Goto Github PK
View Code? Open in Web Editor NEWA command line image processing tool
License: MIT License
A command line image processing tool
License: MIT License
https://imagemagick.org/script/identify.php
When this image library PR lands we can implement a basic version of this feature.
MAP
is essentially shorthand for the array syntax, except each command in the array is the same, and the array is the length of the stack.
i.e.
[gaussian 2.0, gaussian 2.0]
for a stack of size 2 becomes
MAP gaussian 2.0
I recognize that you could also probably do some funky stuff with functions/index of the image on the stack/etc. but just this seems good enough to me.
imagecli -i test.png -o Crop_0_0.png -p 'crop 10 50 100 150'
thread 'main' panicked at '
Unable to parse pipeline.
Consumed: ''
Remaining: 'crop 10 50 100 150'
The error is likely near the start of the remaining (unparsed) text.
', D:\software\cargo\registry\src\github.com-1ecc6299db9ec823\imagecli-0.1.0\src\image_ops.rs:45:13
stack backtrace:
0: 0x7ff6a2a5c489 -
1: 0x7ff6a2a745db -
2: 0x7ff6a2a58a04 -
3: 0x7ff6a2a5ef60 -
4: 0x7ff6a2a5eb8a -
5: 0x7ff6a2a5f7b8 -
6: 0x7ff6a2a5f324 -
7: 0x7ff6a2a5f26f -
8: 0x7ff6a2958492 -
9: 0x7ff6a29299df -
10: 0x7ff6a292918d -
11: 0x7ff6a28b4380 -
12: 0x7ff6a28b2490 -
13: 0x7ff6a2a5f167 -
14: 0x7ff6a2a63b02 -
15: 0x7ff6a2a5fae2 -
16: 0x7ff6a28b49a7 -
17: 0x7ff6a2a79249 -
18: 0x7fff78997974 - BaseThreadInitThunk
19: 0x7fff7aa0a271 - RtlUserThreadStart
Hey there, I keep trying to find this repo by searching "image CLI" on GitHub and not being able to find it because it is one word in the github repo. It would help a lot to add the "image" and "cli" tags to the repo I think.
Create a benchmark that runs all of the examples in the readme.
We already run all examples when generating the readme. Add a regression test that runs all of the examples.
Edit: and update CONTRIBUTING.md when this is done.
For example, lets say it is known that a given pipeline requires 2 input images and 3 output images and the user provides a total of 20 images, it should be possible to split this into 10 different operations right? Thus producing a total of 30 images.
This should be possible to implement because each image operations already have the signature
method that tells how many images goes in and out of it (if possible).
The total output is easy, it should simply be however many images the final step generates.
The total input is a bit tricky because each step may generates additional images, so it needs to take these into account as well.
But I think I have an algorithm that should be able to determine this, but I have no idea if its "correct".
The algorithm to determines the total input images required for a given sequence of image operations is as follows (assuming each of these signature
s return Some(_)
.
Given [(a1,b1), (a2, b2), (a3, b3), ...]
where each tuple is the signature
of each operations.
First, calculate how much extra images each step requires from the previous step.
For the 1st operation, it requires exactly a1
images i.e. a1 - 0
.
The 2nd operations requires a2
images but the 1st step provides b1
images, so it only needs a2 - b1
images.
So on and so forth.
So we have something like,
[a1 - 0, a2 - b1, a3 - b2, ...]
Finally, the total input images required for this pipeline is just the sum of this array.
This will be a breaking change, so I am thinking of an additional flag like --parallel
or something.
Some examples:
-p 'tile <width_px> <height_px>'
would add to the stack, in row-major order, the given image split into tiles of that size.
Basically just a bunch of crop
s: if the image size is not tile-aligned, fill the remainder of that tile with black.
Specifying the tile dimensions means you have to know the image's dimensions to predict how many outputs you will get, which is probably not desirable. A shorter route to some sort of tiling function would be to specify how many tiles you want in x and y: if the caller wants tiles of a certain size, they will have to fill out the main image to something tile-aligned and divide it as appropriate. Then you'd also have to deal with subpixels.
Hey there!
I'm trying to resize my image to a perfect square using the following command, but no matter what I do, it always comes out in the original aspect ratio, instead of squishing or stretching it to make it a square in the dimensions I have provided:
imagecli -i source/$file -o resized/$file -p 'resize 100 100'
Ironically I switched to trying to use imagecli for this exact task after not being able to figure out how to do the same thing in ImageMagik!
Add operations to make it easy to add borders to an image.
βThere aren't currently any image processing operations that produce multiple outputs from a single input.β
This is no longer true - the tile operation splits a single input into multiple outputs.
Add ability to call a limited set of standard functions, e.g. min, max, sin.
Add support for defining functions on pixels rather than just sub pixels. For example, it should be possible to write a function that rotates the red, green and blue channels in an RGB image. (rgb(p.1, p.2, p.0)
?)
hcat
, vcat
and SWAP
do not currently have their own top-level documentation - they just get a mention inside the documentation for grid
and ROT
.
Extend Documentation
to include an aliases section, and pull aliases out into top-level items when generating the README.
There's currently only Circle, and it's pretty clunky to use. Work out a sensible convention for calling drawing functions and add support for lines, rects, etc.
e.g. explain which files couldn't be opened or found rather than just "No such file or directory".
And work out how to handle output names when doing this. Would also need an easy way of determining whether a pipeline should be run on all the images at once, or once per input. One possibility is to always include all input images in the stack and add a MAP operator that applies a function to everything in the stack. Multi-input operations, and multi-stage pipelines both make this slightly more complicated, but should work ok - MAP should walk the stack taking as many inputs as it needs at each point, and then for example you can run MAP DUP > MAP hcat.
The equivalent functionality to image::imageops::crop(img, x, y, w, h) and image::imageops::overlay(bottom, top, x, y).
Hey there, very cool tool. π π A feature I use from imagemagic that imagecli doesn't have yet is the normalize command. I use it to get the best contrast out of my printer scans without having to even open an image editor or tweak any settings.
Some things are currently a bit of a pain to do using a stack.
An example that we should be able to make simpler: create a 2x2 grid with contents:
Top-left: original. Top-right: hflip-ed original. Bottom-left: vflip-ed original. Bottom-right: vflip-ed hflip-ed original.
One possibility is to add a Pipeline (Sequence?) image operation. We could then write the example as DUP 3 > [id, hflip, vflip, hflip > vflip]
. The nesting of array and pipelines could get a bit gnarly, but it should be conceptually simple, and fairly easy to use in practise.
imageproc already has an issue for this: image-rs/imageproc#237.
However, this use case is probably easier - we're in a slightly better position to work out what format an image is in, and apply appropriate conversions at the start and end of the pipeline.
It currently consumes an image before writing the constant output. Support just pushing a new image instead. (This means it won't work with map
. Does that matter?)
Imagemagick allows reading and writing from and to stdin
and stdout
to allow easy integration with pipes and redirection.
Seems like a good feature for a CLI program to have!
We know how many inputs and outputs each operation has before we run the pipeline (although we need to compute this for an Array). Should we add checks that the given pipeline won't try to read from an empty stack, that each input is used, and that all outputs have a corresponding output path?
Even if we don't add the check, we could add num_outputs to the ImageOp trait instead of returning it from the apply method.
-i robin.pg
(note typo) results in no images being found and an error about not having enough images on the stack for the first operation in the pipeline. Before treating all inputs as globs this would have resulted in an error message about not being able to open the non-existent image.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.