# Playground : Photo Collage (from Pixelitor)

Stumbled upon “Pixelitor” today : Pixelitor 4.3.0
One of the effects displayed on their web page caught my eye : Photo Collage

So I’ve tried to recreate it in G’MIC somehow :

``````foo :
foreach { nm={n}
to_rgb
.
100%,100% noise_poissondisk. 20%
0 eval.. "i?(
r1 = u(150,200)/2;
r2 = u(150,200)/2;
pts = mul(rot(u(2*pi)),[ -r1,r1,r1,-r1, -r2,-r2,r2,r2 ],4) + [ x,x,x,x,y,y,y,y ];
da_push([ pts[0],pts[4],pts[1],pts[5],pts[2],pts[6],pts[3],pts[7] ]);
)" da_freeze. rm..
1,100%,1,1,u rv[-2,-1] a[-2,-1] x sort. +,y columns. 1

repeat h {
x0,y0,x1,y1,x2,y2,x3,y3:=I[\$>]

xm,xM,ym,yM:=floor(min(\$x0,\$x1,\$x2,\$x3)),ceil(max(\$x0,\$x1,\$x2,\$x3)),floor(min(\$y0,\$y1,\$y2,\$y3)),ceil(max(\$y0,\$y1,\$y2,\$y3))
+z[0] \$xm,\$ym,\$xM,\$yM
r2dx. 200%,1

100%,100% polygon. 4,{2*[\$x0-\$xm,\$y0-\$ym,\$x1-\$xm,\$y1-\$ym,\$x2-\$xm,\$y2-\$ym,\$x3-\$xm,\$y3-\$ym]},1,1

N=25
frame[-2,-1] \$N,\$N,0,0,0,0
f.. "i(#-1)?I:[255,255,255]" dilate_circ. \$N

*.. . +shift. 10,10 b. 5 n. 0,0.5 max[-2,-1] r2dx[-2,-1] 50%
j[1] ..,{[\$xm,\$ym]-\$N/2},0,0,1,. rm[-2,-1]
}
k[1] => \$nm
}
``````

Not exactly the same but close enough :

``````\$ gmic sp colorful foo
``````

I wonder if this could make a good filter for G’MIC-Qt. Not really happy with the current code (it is quite slow), so maybe I’ll choose another route for doing the effect.
What do you think?

3 Likes

I think the original photo, for each frame, should be slightly rotated and enlarged to make it less perfect but it seems hard to do.

1 Like

Actually it could be fun to do it in 3d. With the image as texture, a bit of thickness and then rotation and all ? Mmm but i don’t know if it can cast shadows.

That is what I would expect as well.

Perhaps a simple smooth warp would make it more interesting.

And also, there isn’t enough photo frames in the example : gaps should be empty or maybe wood (like a table), or maybe there shouldn’t any gaps at all (like in pixelitor)?

Oooo Yes! it will be a very good add to the G’MIC filters IMHO
I would suggest that the picture’s frame to be a 3:2 aspect ratio like cameras/DSLR for landscape and 2:3 for portrait alike or even better give the user 2 sliders W & H for those who want squared or whatever any ratio people wants like in pixelitor.

Out of topic, I love pixelitor, it’s something like 6-7 years that I discovered this wonder, always very nice to play with.

Do you think you will finish this? You could use drop_shadow too now that you’ve rewritten it. Or would it be too slow? I also know that dilate_circ in a loop can slow down things a lot…

5 Likes

New filter Arrays & Tiles / Loose Photos is now available in the G’MIC-Qt plug-in.

Lot of possibilities

(EDIT: 118 lines of code ).

4 Likes

Can the background be transparent?

If you mean the BG where there is no frame : Yes, I’ve just tried. You can set any color.

Now, yes, it can

Oh sorry, in fact my random image was a screenshot of an iris with transparent background, so i thought it was working

5 posts were merged into an existing topic: Pixelitor dev build (4.31) now can use GMIC. if one links it.