This gallery gives a quick overview of the kind of features and generic filters available in the G'MIC open-source image processing framework.
All the images below have been processed by the CLI interface gmic of G'MIC, from a set of initial 2D color images. Click on an image to enlarge it and display the G'MIC command-line used for the processing (note: to reproduce this, you may have to escape some characters, according to the type of shell you use!).
Remember, G'MIC lets you define your own image pipelines through custom command files. Your custom filters can be easily added afterwards in the plug-in for GIMP or Krita.
For more details, visit the tutorial pages as well as the technical reference to get a full documentation on this software.
| Arrays & Frames | Artistic | B&W | Colors | Deformations | Filtering | Patterns | 3D Meshes | Stylization | Code samples |
Rotating Diffusion-Limited Aggregation
#!/usr/bin/env gmic
# File : rotating_dla.gmic
# Author : David Tschumperle
# Entrypoint when run from CLI:
go =>[^] "Rotating Diffusion Limited Aggregation" e[] "" animate 60
# Main function
go :
v 0
480,480 noise 0.001,2 != 0
nbf=300
repeat $nbf { f=$>
e[] "
> Frame "{$f+1}/$nbf
+>[0] 0.45 distance. 1 b. 1 g. xy,6 a[-2--1] c orientation.
1000,1,1,1,":
do (x = v(w#0 - 1); y = v(h#0 - 1), i(#0,x,y));
repeat (w#0,k,
G = I(#-1,x,y,0,1);
dl = 1/max(abs(G));
nx = x - dl*G[0];
ny = y - dl*G[1];
i(#0,round(nx),round(ny))?break();
x = nx; y = ny;
);
i(#0,x,y) = 1"
rm[-2,-1]
# Render frame.
+b[0] 2,3 *. 800 c. 0,255 map. curl
rotate[0] 2,1,0,50%,50% zoom[0] 0.97
}
rm[0]
# End of file.
[ Source code ]
Hilbert Curve
#!/usr/bin/env gmic
# File : hilbert_curve.gmic
# Author : David Tschumperle
# Entrypoint when run from CLI:
go =>[^] "Hilbert Curve" e[] "" animate 60
# Main function
go :
v 0
# Precompute Hilbert curve.
0 eval "
const n = 3 + 1;
const N = 1<>1); ry = 1&xor(t,rx);
!ry?(rx==1?(x = s - 1 - x; y = s - 1 - y); swap(x,y));
x+=s*rx; y+=s*ry; t>>=2;
);
da_push([x,y]);
); da_freeze()" => pts
r. 1,{h*3},1,2,5 b. y,0.1% n. -0.5,0.5
# Generate curve generation frames.
repeat {pts,h} { f=$>
e[] "
> Frame "{$f+1}/{pts,h}
+rows[pts] 0,$> 370,370
eval.. "
begin(
const zoom = lerp(15,0.7,$%^0.1);
const fact = 0.95*w#-1*zoom;
angle = lerp(0,360*4,$%^0.2)°;
R = rot(angle);
Pc = I[-1,2];
);
pP = J[-1,1]; P = I;
pP = Pc + R*(pP - Pc); P = Pc + R*(P - Pc);
Off = lerp(Pc,0,$%^10); pP-=Off; P-=Off;
polygon(#-1,2,round(w#-1/2 + pP*fact),round(w#-1/2 + P*fact),1,1)"
distance. 1 <=. {lerp(20,2.5,$%^0.25)}
+b. {lerp(8,0.5,$%^0.25)}%,3 *. 600 c. 0,255
*.. 255 to_rgb.. map. hot max[-2,-1]
r. 350,350,1,3,0,0,0.5,0.5
rm..
}
rm[0] .x30
# End of file.
[ Source code ]
French Flag
#!/usr/bin/env gmic
# File : french_flag.gmic
# Author : David Tschumperle
# Entrypoint when run from CLI:
go =>[^] "French Flag" e[] "" animate 30
# Main function
go :
v 0
# Render animation frames.
nbf=200
repeat $nbf { f=$>
e[] "
> Frame "{$f+1}/$nbf
300,300,1,3,"*
const f = $f;
const nbf = $nbf;
begin(R = rot(10°*sin(f*2*pi/nbf)));
Z = 80 + 40*cos(x/230 + 2*pi*f/nbf)*sin(y/50 + 3*2*pi*f/nbf);
P = round(R*(Z + 100)*([x,y] - [w,h]/2)%);
(0.4+exp(-Z/60))*(P[0]<-96?[0,0,255]:P[0]<96?[255,255,255]:[255,0,0])*
lerp(0.5,1,xor(P[0]%64,P[1]%64)/64)"
c. 0,255
}
[ Source code ]
Snow
#!/usr/bin/env gmic
# File : snow.gmic
# Author : David Tschumperle
# Entrypoint when run from CLI:
go =>[^] Snow e[] "" animate 60
# Main function
go :
v 0
nbf=400
shape_snowflake 300 repeat 100 { f:=3+0.5*$> +r[0] $f%,$f%,1,1,2 rotate. {lerp(0,90,$>/10)},1,0 } rm[0]
a z,0.5 autocrop. rs. 16
l[] { 8,1,1,{3*1000} rand. 0,1 s c,-3 ap rbf $nbf,0,1 a c }
repeat $nbf { f=$>
e[] "
> Frame "{$f+1}/$nbf
400,400
{1,s/3},1,1,1,"
begin(P = I[#1,"$>"]; S = vector(#w#0*h#0*3,255));
k3 = 3*x;
x = P[k3]*w#-1;
y = P[k3 + 1]*h#-1;
r = round(lerp(0,d#0 - 1,cut(P[k3 + 2],0,1)));
M = crop(#0,0,0,r,w#0,h#0,1);
draw(#-1,S,x,y,0,0,w#0,h#0,1,1,0.75,M);
" rm.
to. "Snow",0.5~,0.5~,${"font macondo,150"},3,1,255
}
rm[0,1]
# End of file.
[ Source code ]
Fire
#!/usr/bin/env gmic
# File : fire.gmic
# Author : David Tschumperle
# Entrypoint when run from CLI:
go =>[^] "Fire" e[] "" animate 60
# Main function
go :
v 0
300,300x2 => trail,canvas
100,100,1,4,"[ u(w#$trail - 1),u(h#$trail - 1),unitnorm([g,g]) ]" => agents
nbf=200
repeat $nbf { f=$>
e[] "
> Frame "{$f+1}"/"$nbf
f[canvas] 0
f[agents] ":begin(
const no = 5; # nb_orientations
const da = 40; # angle
const sd = 10; # sensor_distance;
const md = 5; # move_distance;
# Pre-compute rotation matrices.
Rs = vector(#4*no);
off = 0; repeat (no,k, ang = lerp(-da,da,k/(no - 1)); copy(Rs[off],rot(ang°)); off+=4);
);
A = I; X = A[0,2]; U = A[2,2];
# Get sensor information.
max_orientation = max_value = -inf;
repeat (no,k,
R = Rs[4*k,4];
sX = round(X + sd*mul(R,U));
value = i(#$trail,sX,1,2);
value>max_value?(max_value = value; max_orientation = k);
);
# Turn agent according to sensor measure.
max_orientation = round(max_orientation*(no - 1)/(no - 1));
R = Rs[4*max_orientation,4];
U = lerp(U,mul(R,U),0.2);
# Move agent along new orientation.
X+=md*U;
X[0]%=w#$trail;
X[1]%=h#$trail;
iX = round(X);
++i(#$trail,iX);
ang = atan2(U[1],U[0]);
ellipse(#$canvas,iX,4,1,ang,0.2,255);
[ X,unitnorm(U) ]"
b[trail] 3,2 deform[trail] 2 n[trail] 0,1
+map[canvas] hot
}
k[80--1]
# End of file.
[ Source code ]
3D Cube
#!/usr/bin/env gmic
# File : cube3d.gmic
# Author : David Tschumperle
# Entrypoint when run from CLI:
go =>[^] "3D Cube" e[] "" animate 40
# Main function
go :
v 0
# Create textured checkerboard (floor) and cube.
quadrangle3d 0,0,0,0,1,0,1,1,0,1,0,0 col3d. 0 star3d 5,0.5 *3d. 0.4 +3d. 0.5,0.5 col3d. 1 +3d. 0,0,-1e-2
+col3d.. 2 +col3d.. 3 +3d[-4,-3] +3d[-2,-1] +rv +3d[-3,-1] 1,0,0 +3d[-2,-1] 0,1,0 +3d array3d 16,16 => floor
box3d 1,1,1 l. { s3d. f.. 6+2*int(y/3) a y } => cube
(16^32^96;16^16^32;0^0^0) r. 512,512,1,3,3 => background
18,1,1,3,"x>=4?[64,0,32]:[0,0,0]" => colormap
# Generate animation.
nbf,f:=6*16,1 srand 5
repeat 6 {
dir:=arg0($>,0,3,0,2,2,0)
shift:=arg0($dir,[1,0,1],[0,0,1],[1,0,1],[1,1,1])
axis:=arg0($dir,[0,-1,0],[0,1,0],[-1,0,0],[1,0,0])
scroll:=arg0($dir,[-1,0,0],[1,0,0],[0,1,0],[0,-1,0])
repeat $nbf/6 { t:=$>/($>+$<+1)
e[] "
> Frame "$f"/"$nbf f+=1
ang:=lerp(0,90,$t)
+-3d[cube] $shift r3d. $axis,$ang +3d. $shift # Rotate cube around bottom edge
+3d. 16,16,-1 +3d. [floor] # Place cube on the floor
+3d. {$t*[$scroll]} # Scroll floor
-3d. 16,16,0 *3d. 110 r3d. 0,0,1,35 r3d. 1,0,0,-50 # Rotate whole object to have a nice view
{background,[w,h]}
j3d. ..,50%,50%,0,1,2,0,1,400 # Draw object on canvas
+f. "const boundary=1; M = abs(maxabs(i - j(1),i - j(0,1))); M>1?1:M>0?0.3:0"
*. 255 dilate. 2 # Render as black & white outline
map.. [colormap]
max[-2,-1] max. [background]
+b. 10,0 n. 0,200 +[-2,-1] c. 0,255
rows. 10,100% # Remove ugly top part due to 3D perspective
rs. 480
rm..
}
}
k[4--1]
# End of file.
[ Source code ]
3D Tunnel
#!/usr/bin/env gmic
# File : tunnel3d.gmic
# Author : David Tschumperle
# Entrypoint when run from CLI:
go =>[^] "Tunnel 3D" e[] "" animate 30
# Main function
go :
v 0
# Generate template mesh for the 3D tunnel.
curve3d 0,0,t,1,64,0,63,16,0 rv3d # Generate a straight bar along z-axis
s3d eval "i[#1,1]-=32" rows... 0,{-3,h-4*32-1} rows.. 0,{-2,h-3*32-1} rows. 0,{h-32-1} a y # Remove closed extremities
2,1024,1,3,"x?[255,200,128]:[255,0,0]"
(0^0^0;0.25^0.25^1;1^1^1;0^0^0)
2,{-2,h},1,3,"Y = lerp(0,h#-1,(y/h)^0.5); cut(I(#-1,0,Y,0,2),0,1)" rm.. *[-2,-1] # Colors for depth shading
t3d.. . rm. . => template3d,mesh3d
+l. { s3d off_p:=8+{2,h} k... r 13,{h/13},1,1,-1 permute zycx } => primitives # Keep editable version of primitives
# Generate sequence of 3D tunnel centers.
1,48,1,2,g b. y,4,2 n. -1.5,2 a. .,y => coords
+g. y b. 1,2 channels. 0,2 sh. 100% f. 1 rm. orientation. => orientations # Desired camera orientations
# Display animation
nbf=256 mzi2=-inf
repeat $nbf { f=$>
e[] "
> Frame "{$f+1}"/"$nbf
z:=16+lerp(0,h#$coords/2,$>/$nbf)
zi2:=2*int($z/2)
if $zi2!=$mzi2 # Generate 3D mesh for current tunnel view.
+z[template3d] 0,8,0,{template3d,8+3*i[6]-1} r. 3,{h/3},1,1,-1 permute. zycx # Extract 3D coordinates
f. "C = I[#$coords,$zi2 + i2,2]; [ i0 + C[0],i1 + C[1],i2 ]"
permute. cyzx y. +j[template3d] .,0,8,0,0 rm..
mzi2:=$zi2
j[mesh3d] . rm.
fi
cx,cy:="I(#$coords,0,$z,0,2,2)"
u,v,w:="unitnorm(I(#$orientations,0,$z,0,2,2))"
M:="W = unitnorm(I(#$orientations,0,$z,0,2,2)); V = cross(W,[1,0,0]); U = cross(V,W); 1.5*[ U,V,W ]" # Camera matrix
+-3d[mesh3d] $cx,$cy,{$z%2}
apply_matrix3d. $M
r3d. 0,0,1,{180*cos(2*pi*$>/$nbf)}
# Add depth effect.
f[primitives] "
P = I;
z = int(y/16);
P[5] = P[7] = P[9] = P[11] = xor(z,y)%2;
P[6] = 16*i[#-1,8+3*i1+2];
P[8] = 16*i[#-1,8+3*i2+2];
P[10] = 16*i[#-1,8+3*i3+2];
P[12] = 16*i[#-1,8+3*i4+2];
P"
+permute[primitives] cyzx y. j.. .,0,$off_p rm.
# Render frame.
600,600,1,3
j3d. ..,50%,50%,-500,1,2,0,0,500 rm..
}
k[5--1] rs 320 a z n 0,255 s z round
# End of file.
[ Source code ]
Morph Shape
#!/usr/bin/env gmic
# File : morphshape.gmic
# Author : David Tschumperle
# Entrypoint when run from CLI:
go =>[^] "Morph Shape" e[] "" animate 30
# Main function
go :
v 0
shape_cupid 500 # Source shape
shape_dragonfly 500 # Target shape
ge 50% r 512,512,1,1,0,0,0.5,0.5
# Extract contour parameterizations of largest components.
foreach { edgels -1 k[{argmax(${"-lof h"})}] channels. 0,1 f. "I==J[-1]?[-1,-1]:I" discard. -1 r. 1,50%,1,2,-1 }
r 1,${-max_h},1,2,1 1,32,1,1,y%4 r. 1,{-2,h} a[-3,-2] .,c rm.
=> source,target
512,512,1,3,"lerp([0,64,0],[0,32,128],y/h)" => background
(0^0^0^0,255^255^255^255,255^0^0^255,255^128^0^255,255^255^0^255) => colormap
# Perform curve interpolation.
repeat 50 {
k:=cut(lerp(-0.15,1.15,$%),0,1)
[source] sh. 0,1 b. y,{lerp(0,100,$k)},2 rm.
[target] sh. 0,1 b. y,{lerp(100,0,$k)},2 rm.
j.. .,0,0,0,0,$k rm.
{background,[w,h]} eval.. "pP = J[-1,2]; polygon(#-1,2,pP[0],pP[1],i0,i1,1,i2 + 1)"
dilate. 3 map. [colormap] +ja[background] .
rm[-3,-2]
}
rm[source,target,background,colormap]
+rv
# End of file.
[ Source code ]
Pacman
#!/usr/bin/env gmic
# File : pacman.gmic
# Author : David Tschumperle
# Entrypoint when run from CLI:
go =>[^] Pacman e[] "" animate 60
# Main function
go :
v 0
# Create background image = [0].
500,300,1,3
line 0,8%,100%,8%,1,1
line 0,92%,100%,92%,1,1
blur y,5%,1 * '[64,32,255]' normalize 0,255
# Create image of pellets = [1].
shape_circle 30
resize. 300%,100%,1,1,0,0,0.5 W:=w
resize. ..,100%,1,1,0,2
# Create colormap = [2].
(0,0,0;255,255,255;255,255,0) permute. yzcx
nbf=20
repeat $nbf { f=$>
e[] "
> Frame "{$f+1}/$nbf
[0],[0] circle. 30%,50%,15%,1,2
y:=h/2-2*h*($f<$nbf/2?$f:$nbf-$f)/$nbf
polygon. 3,30%,50%,100%,$y,100%,{h-$y}
+fill. 0 image. [1],{w/10+2*$W*(1-$f/$nbf)},{(h-h#1)/2}
max[-2,-1] map. [2] max. [0]
}
remove[0-2]
# End of file.
[ Source code ]
Scrolling
#!/usr/bin/env gmic
# File : scrolling.gmic
# Author : David Tschumperle
# Entrypoint when run from CLI:
go =>[^] Scrolling e[] "" animate 50
# Main function
go :
v 0
srand 32
# Define rendering sizes.
wf,hf=512,384
wr,hr:=round(1.5*[$wf,$hf])
# Generate image [0] = line of text.
input 0 text "G'MIC rocks ! ",0,0,48,1,1 wt,ht:=[w,h] resize {2.5*$wr},100%,1,1,0,2
# Generate image [1] = color gradient.
input {10*ceil($hr/$ht)},1,1,3,u(64,255) tsp. , transpose. resize. $wr,$hr,1,3,3
# Generate image [2] = 3d cube (3d object).
box3d {$wr/3} color3d. 255,32,200 center3d.
# Generate animation frames.
nbf=50
repeat $nbf { f=$>
e[] "
> Frame "{$f+1}/$nbf
input $wr,$hr,1,1
repeat ceil($hr/$ht) {
image. [0],{w/5*cos($>/3+2*pi*$f/$nbf)-$wt*(1+$f/$nbf)},{$>*$ht}
}
+mul[1,-1] remove..
rotate. 25,1,0
resize. $wf,$hf,1,100%,0,0,0.5,0.5
+fill. 0
+rotate3d[2] 1,-1,0,{180*$f/$nbf} rotate3d. 0,1,0,{360*$f/$nbf} rotate3d. 1,2,3,-60
object3d.. .,50%,50%,100,1,3,0,0
remove. div. 1.6 max[-2,-1]
}
keep[3--1]
# End of file.
[ Source code ]
Landscape
400 Bad Request Bad Request
Your browser sent a request that this server could not understand.
[ Source code ]
Mandelbrot
400 Bad Request Bad Request
Your browser sent a request that this server could not understand.
[ Source code ]
Lissajous
400 Bad Request Bad Request
Your browser sent a request that this server could not understand.
[ Source code ]
3D torus
400 Bad Request Bad Request
Your browser sent a request that this server could not understand.
[ Source code ]
Heart
400 Bad Request Bad Request
Your browser sent a request that this server could not understand.
[ Source code ]
| Arrays & Frames | Artistic | B&W | Colors | Deformations | Filtering | Patterns | 3D Meshes | Stylization | Code samples |


Home
Download
News
Mastodon
Bluesky
X
Summary - 17 Years
Summary - 16 Years
Summary - 15 Years
Summary - 13 Years
Summary - 11 Years
Summary - 10 Years
Resources
Technical Reference
Scripting Tutorial
Video Tutorials
Wiki Pages
Image Gallery
Color Presets
Using libgmic
G'MIC Online
Community
Discussion Forum (Pixls.us)
GimpChat
IRC
Report Issue