Primitive is a cli program that takes your input image(s) make cool looking art with them using basic shapes, find the github page here, primitive does not come with a binary executable by default, you can either install golang and compile it yourself or download the binary version of windows or linux from my repo here
everything is downloaded from a royalty free image website here
Flag | Default | Description |
---|---|---|
i |
n/a | input file |
o |
n/a | output file |
n |
n/a | number of shapes |
m |
1 | mode: 0=combo, 1=triangle, 2=rect, 3=ellipse, 4=circle, 5=rotatedrect, 6=beziers, 7=rotatedellipse, 8=polygon |
rep |
0 | add N extra shapes each iteration with reduced search (mostly good for beziers) |
nth |
1 | save every Nth frame (only when %d is in output path) |
r |
256 | resize large input images to this size before processing |
s |
1024 | output image size |
a |
128 | color alpha (use 0 to let the algorithm choose alpha for each shape) |
bg |
avg | starting background color (hex) |
j |
0 | number of parallel workers (default uses all cores) |
v |
off | verbose output |
vv |
off | very verbose output |
primitive -i cheetah.jpg -o c_0.jpg -n 1000 -m 0 -s 1280 -v
primitive -i lion.jpg -o l_0.jpg -n 500 -m 0 -s 1280 -v
primitive -i cow.jpg -o c2_0.jpg -n 250 -m 0 -s 1280 -v
primitive -i monkey.jpg -o m_1.jpg -n 500 -m 1 -s 1280 -v
primitive -i flamingo.jpg -o f_1.jpg -n 750 -m 1 -s 1280 -v
primitive -i flamingo.jpg -o f_1.jpg -n 750 -m 1 -s 1280 -v
primitive -i zebra.jpg -o z_2.jpg -n 500 -m 2 -s 1280 -v
primitive -i ostrich.jpg -o o_2.jpg -n 250 -m 2 -s 1280 -v
primitive -i camel.jpg -o c_2.jpg -n 1000 -m 2 -s 1280 -v
primitive -i panda.jpg -o p_3.jpg -n 750 -m 3 -s 1280 -v
primitive -i elephant.jpg -o e_3.jpg -n 500 -m 3 -s 1280 -v
primitive -i chicken.jpg -o c_3.jpg -n 1000 -m 3 -s 1280 -v
primitive -i bunny.jpg -o b_4.jpg -n 1000 -m 4 -s 1280 -v
primitive -i crab.jpg -o c_4.jpg -n 250 -m 4 -s 1280 -v
primitive -i dog.jpg -o d_4.jpg -n 500 -m 4 -s 1280 -v
primitive -i shark.jpg -o s_5.jpg -n 250 -m 5 -s 1280 -v
primitive -i horse.jpg -o h_5.jpg -n 500 -m 5 -s 1280 -v
primitive -i penguin.jpg -o p_5.jpg -n 750 -m 5 -s 1280 -v
for beziers we also use the -rep 10
switch which multiplies the number of shapes by 10 for each iteration its adding, this is because lines are harder to make out if not many of them are present
primitive -i fox.jpg -o f_6.jpg -n 500 -m 6 -s 1280 -rep 10 -v
primitive -i wolf.jpg -o w_6.jpg -n 250 -m 6 -s 1280 -rep 10 -v
primitive -i cat.jpg -o c_6.jpg -n 750 -m 6 -s 1280 -rep 10 -v
primitive -i hamster.jpg -o h_7.jpg -n 500 -m 7 -s 1280 -v
primitive -i fish.jpg -o f_7.jpg -n 250 -m 7 -s 1280 -v
primitive -i fish.jpg -o f_7.jpg -n 250 -m 7 -s 1280 -v
primitive -i butterfly.jpg -o b_8.jpg -n 250 -m 8 -s 1280 -v
primitive -i hawk.jpg -o h_8.jpg -n 100 -m 8 -s 1280 -v
primitive -i deer.jpg -o d_8.jpg -n 500 -m 8 -s 1280 -v
each time you convert an image with primitive the output is different even with the same setting switches, this makes creating animated gifs very easy, just duplicate your image a few times, convert them with primitive
for i in *.jpg ; do echo $i ; primitive -i $i -o p-$i -n 500 -m 0 -v ; done
and then mux them together
cat p-bird*.jpg | ffmpeg -framerate 5 -f image2pipe -i - bird.gif
lets convert this image 10 times with the same settings in one command
for t in {1..10} ; do echo $t ; primitive -i koala.jpg -o k-$t.jpg -n 500 -m 1 -v ; done
and mux the images
cat k-* | ffmpeg -framerate 10 -f image2pipe -i - koala.gif
lets convert this image 100 times with every image having 1 shape count more than the last one, starting at 1 shapes count and ending on 100
for t in {1..100} ; do echo $t ; primitive -i spider.jpg -o s-$t.jpg -n $t -m 0 -v ; done
and mux the images
cat s-* | ffmpeg -framerate 15 -f image2pipe -i - spider.mp4
the outpot gif was quite large so i decided to add this as a mp4 video, you can have the video looped forever by right clicking on it and tick on loop
lets convert this image 100 times, starting with 1 shape and then 6 and 11 and 16 etc to get to 500 shapes in the 100th picture …
for t in {001..500..5} ; do echo $t ; primitive -i buffalo.jpg -o b-$t.jpg -n $t -m 5 -v ; done
and mux the images
cat b-* | ffmpeg -framerate 15 -f image2pipe -i - buffalo.mp4
lets apply what we learned to a video, i have made a example of how to download a free video, make image sequence, apply filter and mux it back here
for i in image-000*.jpg ; do echo $i ; primitive -i $i -o p-$i.jpg -n 250 -m 0 -s 1280 -v ; done
and mux the images
cat p-image-000*.jpg | ffmpeg -framerate 30 -f image2pipe -i - fish+.mp4
there is also my repo with easy to use bat and scripts to make life easier for batch proccessing