-
Notifications
You must be signed in to change notification settings - Fork 0
/
photobot.leo
5921 lines (4602 loc) · 141 KB
/
photobot.leo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<!-- Created by Leo: http://leoeditor.com/leo_toc.html -->
<leo_file xmlns:leo="http://leoeditor.com/namespaces/leo-python-editor/1.1" >
<leo_header file_format="2" tnodes="0" max_tnode_index="0" clone_windows="0"/>
<globals body_outline_ratio="0.5" body_secondary_ratio="0.5">
<global_window_position top="50" left="50" height="500" width="700"/>
<global_log_window_position top="0" left="0" height="0" width="0"/>
</globals>
<preferences/>
<find_panel_settings/>
<vnodes>
<v t="karstenw.20170709210040.1" a="E"><vh>@clean photobot/__init__.py</vh>
<v t="karstenw.20170709210125.1"><vh>Declarations</vh></v>
<v t="karstenw.20230114013608.1"><vh>Py2/3 stuff</vh></v>
<v t="karstenw.20200421130950.1"><vh>Globals</vh></v>
<v t="karstenw.20200419210659.1"><vh>Photobot</vh>
<v t="karstenw.20170709210125.5"><vh>class Canvas</vh>
<v t="karstenw.20170709210125.6"><vh>__init__</vh></v>
<v t="karstenw.20170709210125.7"><vh>layer</vh></v>
<v t="karstenw.20170709210125.8"><vh>fill</vh></v>
<v t="karstenw.20170709210125.9"><vh>makegradientimage</vh>
<v t="karstenw.20210301171902.1"><vh><< init >></vh></v>
<v t="karstenw.20210301172848.1"><vh><< solid >></vh></v>
<v t="karstenw.20210301172906.1"><vh><< linear >></vh></v>
<v t="karstenw.20210301172912.1"><vh><< radial >></vh></v>
<v t="karstenw.20210301172925.1"><vh><< radialcosine >></vh></v>
<v t="karstenw.20210301172931.1"><vh><< diamond >></vh></v>
<v t="karstenw.20210803163323.1"><vh><< scatter >></vh></v>
<v t="karstenw.20210301172939.1"><vh><< sine cosine >></vh></v>
</v>
<v t="karstenw.20170709210125.10"><vh>gradient</vh>
<v t="karstenw.20210301172109.1"><vh><< init >></vh></v>
<v t="karstenw.20210301172149.1"><vh><< one Image gradients >></vh></v>
<v t="karstenw.20210301172433.1"><vh><< quad gradient >></vh></v>
<v t="karstenw.20210301172509.1"><vh><< roundrect gradient >></vh></v>
</v>
<v t="karstenw.20210722112540.1"><vh>EXPORT</vh>
<v t="karstenw.20170709210125.11"><vh>merge</vh></v>
<v t="karstenw.20170709210125.12"><vh>flatten</vh></v>
<v t="karstenw.20170709210125.13" a="E"><vh>export</vh>
<v t="karstenw.20200430120922.1"><vh><<init>></vh></v>
<v t="karstenw.20200430120955.1"><vh><<debug>></vh></v>
</v>
<v t="karstenw.20170709210125.14"><vh>draw</vh></v>
</v>
<v t="karstenw.20170709210125.15"><vh>preferences</vh></v>
<v t="karstenw.20200430120743.1"><vh>STACK OPS</vh>
<v t="karstenw.20170710142919.1"><vh>top</vh></v>
<v t="karstenw.20210722112454.1"><vh>topindex</vh></v>
<v t="karstenw.20200430124808.1"><vh>dup</vh></v>
</v>
<v t="karstenw.20210722112739.1"><vh>copy</vh></v>
</v>
<v t="karstenw.20170709210125.17"><vh>class Layers</vh>
<v t="karstenw.20170709210125.18"><vh>__getitem__</vh></v>
<v t="karstenw.20170709210125.19"><vh>_get_bg</vh></v>
<v t="karstenw.20170709210125.20"><vh>_set_bg</vh></v>
</v>
<v t="karstenw.20170709210125.21"><vh>class Layer</vh>
<v t="karstenw.20170709210125.22"><vh>__init__</vh></v>
<v t="karstenw.20170709210125.23"><vh>prnt</vh></v>
<v t="karstenw.20170709210125.24"><vh>index</vh></v>
<v t="karstenw.20170709210125.25"><vh>copy</vh></v>
<v t="karstenw.20170709210125.26"><vh>delete</vh></v>
<v t="karstenw.20170709210125.27"><vh>up</vh></v>
<v t="karstenw.20170709210125.28"><vh>down</vh></v>
<v t="karstenw.20170709210125.29"><vh>bounds</vh></v>
<v t="karstenw.20170709210125.30"><vh>select</vh></v>
<v t="karstenw.20170709210125.31"><vh>mask</vh></v>
<v t="karstenw.20170709210125.32"><vh>duplicate</vh></v>
<v t="karstenw.20170727231803.1"><vh>BLENDS</vh>
<v t="karstenw.20170709210125.33"><vh>opacity</vh></v>
<v t="karstenw.20170709210125.34"><vh>multiply</vh></v>
<v t="karstenw.20200419182817.1"><vh>add</vh></v>
<v t="karstenw.20200419182824.1"><vh>subtract</vh></v>
<v t="karstenw.20200419182831.1"><vh>add_modulo</vh></v>
<v t="karstenw.20200419182838.1"><vh>subtract_modulo</vh></v>
<v t="karstenw.20200419182844.1"><vh>difference</vh></v>
<v t="karstenw.20170709210125.35"><vh>screen</vh></v>
<v t="karstenw.20170709210125.36"><vh>overlay</vh></v>
<v t="karstenw.20170709210125.37"><vh>hue</vh></v>
<v t="karstenw.20170709210125.38"><vh>color</vh></v>
</v>
<v t="karstenw.20170727231827.1"><vh>INTENSITIES</vh>
<v t="karstenw.20170709210125.39"><vh>brightness</vh></v>
<v t="karstenw.20170709210125.40"><vh>contrast</vh></v>
<v t="karstenw.20170709210125.41"><vh>desaturate</vh></v>
<v t="karstenw.20170709210125.42"><vh>colorize</vh></v>
<v t="karstenw.20210727161432.1"><vh>posterize</vh></v>
<v t="karstenw.20210727161432.2"><vh>solarize</vh></v>
<v t="karstenw.20210727161432.3"><vh>autocontrast</vh></v>
<v t="karstenw.20210727161432.4"><vh>deform</vh></v>
<v t="karstenw.20210727161432.5"><vh>equalize</vh></v>
<v t="karstenw.20170709210125.43"><vh>invert</vh></v>
</v>
<v t="karstenw.20170727232236.1"><vh>GEOMETRY</vh>
<v t="karstenw.20170709210125.44"><vh>translate</vh></v>
<v t="karstenw.20170709210125.45"><vh>scale</vh></v>
<v t="karstenw.20170709210125.47"><vh>rotate</vh></v>
<v t="karstenw.20170709210125.46"><vh>distort</vh></v>
<v t="karstenw.20170709210125.48"><vh>flip</vh></v>
<v t="karstenw.20170727233343.1"><vh>crop</vh></v>
</v>
<v t="karstenw.20200421172034.1"><vh>FILTERS</vh>
<v t="karstenw.20170727232434.1"><vh>autocontrast</vh></v>
<v t="karstenw.20170709210125.49"><vh>blur</vh></v>
<v t="karstenw.20200421172500.1"><vh>new boxblur</vh></v>
<v t="karstenw.20200419183112.1"><vh>new contour</vh></v>
<v t="karstenw.20200419183129.1"><vh>new detail</vh></v>
<v t="karstenw.20200419183142.1"><vh>new edge_enhance</vh></v>
<v t="karstenw.20200419183156.1"><vh>new edge_enhance_more</vh></v>
<v t="karstenw.20200419183210.1"><vh>new emboss</vh></v>
<v t="karstenw.20200419183218.1"><vh>new find_edges</vh></v>
<v t="karstenw.20200419183225.1"><vh>new smooth</vh></v>
<v t="karstenw.20200419183232.1"><vh>new smooth_more</vh></v>
<v t="karstenw.20170709210125.50"><vh>sharpen</vh></v>
<v t="karstenw.20200421172203.1"><vh>convolute</vh></v>
</v>
<v t="karstenw.20170709210125.51"><vh>statistics</vh></v>
<v t="karstenw.20170709210125.52"><vh>levels</vh></v>
</v>
<v t="karstenw.20170709210125.53"><vh>class Blend</vh>
<v t="karstenw.20210301161622.1"><vh>subtract</vh></v>
<v t="karstenw.20210301161642.1"><vh>subtract_modulo</vh></v>
<v t="karstenw.20170709210125.54"><vh>overlay</vh></v>
<v t="karstenw.20170709210125.55"><vh>hue</vh></v>
<v t="karstenw.20170709210125.56"><vh>color</vh></v>
</v>
<v t="karstenw.20170709210125.57"><vh>class Pixels</vh>
<v t="karstenw.20170709210125.58"><vh>__init__</vh></v>
<v t="karstenw.20170709210125.59"><vh>__getitem__</vh></v>
<v t="karstenw.20170709210125.60"><vh>__setitem__</vh></v>
<v t="karstenw.20170709210125.61"><vh>__iter__</vh></v>
<v t="karstenw.20170709210125.62"><vh>__len__</vh></v>
<v t="karstenw.20170709210125.63"><vh>update</vh></v>
<v t="karstenw.20170709210125.64"><vh>convolute</vh></v>
</v>
</v>
<v t="karstenw.20200419183424.1"><vh>Nodebox & standalone pillow tools</vh>
<v t="karstenw.20200419185608.1"><vh>makeunicode</vh></v>
<v t="karstenw.20210603134137.1"><vh>uniquepath</vh></v>
<v t="karstenw.20200419185543.1"><vh>hashFromString</vh></v>
<v t="karstenw.20200419185624.1"><vh>datestring</vh></v>
<v t="karstenw.20211021133612.1"><vh>grid</vh></v>
</v>
<v t="karstenw.20201022144341.1" a="E"><vh>Imagetools</vh>
<v t="karstenw.20200419184424.1"><vh>invertimage</vh></v>
<v t="karstenw.20200419184433.1"><vh>cropimage</vh></v>
<v t="karstenw.20210612104640.1"><vh>splitrect</vh></v>
<v t="karstenw.20211021151303.1"><vh>splitimage</vh></v>
<v t="karstenw.20210301171313.1" a="E"><vh>++ REFACTOR ++</vh>
<v t="karstenw.20170709210125.65"><vh>aspectRatio</vh></v>
<v t="karstenw.20201022144702.1"><vh>innerRect</vh></v>
<v t="karstenw.20200419185026.1"><vh>insetRect</vh></v>
<v t="karstenw.20200419185034.1"><vh>cropImageToRatioHorizontal</vh></v>
<v t="karstenw.20200419185042.1"><vh>scaleLayerToHeight</vh></v>
<v t="karstenw.20200419185049.1"><vh>placeImage</vh></v>
<v t="karstenw.20200419185056.1"><vh>resizeImage</vh></v>
</v>
<v t="karstenw.20170709210125.66"><vh>normalizeOrientationImage</vh></v>
</v>
<v t="karstenw.20210301171559.1"><vh>Text</vh>
<v t="karstenw.20200419184336.1"><vh>label</vh></v>
</v>
</v>
<v t="karstenw.20201006211515.1" a="E"><vh>examples</vh>
<v t="karstenw.20210319153803.1" a="E"><vh>Collagen</vh>
<v t="karstenw.20201006211521.1" a="E"><vh>@clean examples/Example collage 1.py</vh>
<v t="karstenw.20201006211613.1"><vh>Declarations</vh></v>
<v t="karstenw.20230115124413.1"><vh>Image folders</vh></v>
<v t="karstenw.20201006211627.1"><vh>init</vh></v>
<v t="karstenw.20210331155153.1"><vh>shuffle tiles</vh></v>
<v t="karstenw.20220409174745.1"><vh>background image</vh></v>
<v t="karstenw.20210316183613.1"><vh>config</vh></v>
<v t="karstenw.20210316183643.1"><vh>loop</vh></v>
<v t="karstenw.20210316183734.1" a="E"><vh>finish</vh>
<v t="karstenw.20210316200041.1"><vh><< orange gilb >></vh></v>
<v t="karstenw.20210316200115.1"><vh><< paint texture >></vh></v>
</v>
</v>
<v t="karstenw.20201006211549.1" a="E"><vh>@clean examples/Example collage 1a.py</vh>
<v t="karstenw.20201006211613.1"></v>
<v t="karstenw.20230115124413.1"></v>
<v t="karstenw.20201006211627.1"></v>
<v t="karstenw.20210331155153.1"></v>
<v t="karstenw.20220409174745.1"></v>
<v t="karstenw.20210316200956.1"><vh>config</vh></v>
<v t="karstenw.20210314151702.1"><vh>loop</vh></v>
<v t="karstenw.20210314151706.1"><vh>finish</vh>
<v t="karstenw.20210316200041.1"></v>
<v t="karstenw.20210316200115.1"></v>
</v>
</v>
<v t="karstenw.20210316195906.1" a="E"><vh>@clean examples/Example collage 1b.py</vh>
<v t="karstenw.20201006211613.1"></v>
<v t="karstenw.20230115124413.1"></v>
<v t="karstenw.20201006211627.1"></v>
<v t="karstenw.20210331155153.1"></v>
<v t="karstenw.20220409174745.1"></v>
<v t="karstenw.20210316201117.1"><vh>config</vh></v>
<v t="karstenw.20210316201120.1"><vh>loop</vh></v>
<v t="karstenw.20210316201125.1"><vh>finish</vh>
<v t="karstenw.20210317123345.1"><vh><< orange gilb >></vh></v>
<v t="karstenw.20210316200115.1"></v>
</v>
</v>
<v t="karstenw.20210317152421.1" a="E"><vh>@clean examples/Example collage 2.py</vh>
<v t="karstenw.20201006211613.1"></v>
<v t="karstenw.20230115124413.1"></v>
<v t="karstenw.20201006211627.1"></v>
<v t="karstenw.20210331155153.1"></v>
<v t="karstenw.20220409174745.1"></v>
<v t="karstenw.20210317152601.1"><vh>config</vh></v>
<v t="karstenw.20210317152606.1" a="E"><vh>loop</vh>
<v t="karstenw.20210317154410.1"><vh><< place image >></vh></v>
<v t="karstenw.20210317154416.1"><vh><< create gradients >></vh></v>
<v t="karstenw.20210317154440.1"><vh><< flip and blur >></vh></v>
<v t="karstenw.20210317154705.1"><vh><< layer post processing >></vh></v>
</v>
<v t="karstenw.20210317152611.1"><vh>finish</vh>
<v t="karstenw.20210316200041.1"></v>
<v t="karstenw.20210316200115.1"></v>
</v>
</v>
<v t="karstenw.20210317152433.1" a="E"><vh>@clean examples/Example collage 3.py</vh>
<v t="karstenw.20201006211613.1"></v>
<v t="karstenw.20230115124413.1"></v>
<v t="karstenw.20201006211627.1"></v>
<v t="karstenw.20210331155153.1"></v>
<v t="karstenw.20210319130640.1"><vh>grid</vh></v>
<v t="karstenw.20220409174745.1"></v>
<v t="karstenw.20210319124939.2"><vh>config</vh></v>
<v t="karstenw.20210319124939.3"><vh>loop</vh></v>
<v t="karstenw.20210319124940.1"><vh>finish</vh></v>
</v>
<v t="karstenw.20210317152441.1" a="E"><vh>@clean examples/Example collage 4.py</vh>
<v t="karstenw.20201006211613.1"></v>
<v t="karstenw.20230115124413.1"></v>
<v t="karstenw.20201006211627.1"></v>
<v t="karstenw.20210331155153.1"></v>
<v t="karstenw.20210319130640.1"></v>
<v t="karstenw.20220409174745.1"></v>
<v t="karstenw.20210319125114.1"><vh>config</vh></v>
<v t="karstenw.20210319125121.1" a="E"><vh>loop</vh>
<v t="karstenw.20210331165116.1"><vh><< tile blur >></vh></v>
</v>
<v t="karstenw.20210319141308.1"><vh>finish</vh>
<v t="karstenw.20210316200041.1"></v>
<v t="karstenw.20210316200115.1"></v>
</v>
</v>
<v t="karstenw.20210331161145.1" a="E"><vh>@clean examples/Example collage 5.py</vh>
<v t="karstenw.20201006211613.1"></v>
<v t="karstenw.20230115124413.1"></v>
<v t="karstenw.20201006211627.1"></v>
<v t="karstenw.20210331155153.1"></v>
<v t="karstenw.20210319130640.1"></v>
<v t="karstenw.20220409174745.1"></v>
<v t="karstenw.20210331161336.1"><vh>config</vh></v>
<v t="karstenw.20210331161342.1" a="E"><vh>loop</vh>
<v t="karstenw.20210331164744.1"><vh><< image placement >></vh></v>
<v t="karstenw.20210331164848.1"><vh><< tile height >></vh></v>
<v t="karstenw.20210331165305.1"><vh><< tile contrast crank >></vh></v>
<v t="karstenw.20210331164758.1"><vh><< create up down ramp mask >></vh></v>
<v t="karstenw.20210331165103.1"><vh><< tile translation >></vh></v>
<v t="karstenw.20210331165110.1"><vh><< opacity >></vh></v>
<v t="karstenw.20210331165116.1"></v>
</v>
<v t="karstenw.20210331161246.1" a="E"><vh>finish</vh>
<v t="karstenw.20210316200041.1"></v>
<v t="karstenw.20210316200115.1"></v>
</v>
</v>
<v t="karstenw.20211005225841.1"><vh>@clean examples/Example collage 6.py</vh>
<v t="karstenw.20201006211613.1"></v>
<v t="karstenw.20230115124413.1"></v>
<v t="karstenw.20201006211627.1"></v>
<v t="karstenw.20210331155153.1"></v>
<v t="karstenw.20210319130640.1"></v>
<v t="karstenw.20220409174745.1"></v>
<v t="karstenw.20211005225906.2"><vh>config</vh></v>
<v t="karstenw.20211005233913.1"><vh>loop</vh>
<v t="karstenw.20210331164744.1"></v>
<v t="karstenw.20210331164848.1"></v>
<v t="karstenw.20210331165305.1"></v>
<v t="karstenw.20211005234613.1"><vh><< create scatter mask >></vh></v>
<v t="karstenw.20210331165103.1"></v>
<v t="karstenw.20210331165110.1"></v>
<v t="karstenw.20210331165116.1"></v>
</v>
<v t="karstenw.20211005230001.1"><vh>finnish</vh>
<v t="karstenw.20210316200041.1"></v>
<v t="karstenw.20210316200115.1"></v>
</v>
</v>
</v>
<v t="karstenw.20210319153818.1"><vh>Filters and Functions</vh>
<v t="karstenw.20211206121916.1"><vh>@clean examples/explore_gradients 1.py</vh>
<v t="karstenw.20211206121944.1"><vh>Declarations</vh></v>
</v>
<v t="karstenw.20211206134707.1"><vh>@clean examples/Layer_colorize.py</vh>
<v t="karstenw.20211206131524.1"><vh>Declarations</vh></v>
<v t="karstenw.20211206134707.2"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206122120.1"><vh>@clean examples/Layer_filter_boxblur.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206122136.1"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206123730.1"><vh>@clean examples/Layer_filter_contour.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206123730.2"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206123753.1"><vh>@clean examples/Layer_filter_edge_enhance_more.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206123753.2"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206123754.1"><vh>@clean examples/Layer_filter_edge_enhance.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206123754.2"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206123755.1"><vh>@clean examples/Layer_filter_emboss.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206123755.2"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206123755.3"><vh>@clean examples/Layer_filter_find_edges.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206123755.4"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206123755.5"><vh>@clean examples/Layer_function_add_modulo.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206123755.6"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206123755.7"><vh>@clean examples/Layer_function_add.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206123755.8"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206123755.9"><vh>@clean examples/Layer_function_autocontrast.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206123755.10"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206123755.11"><vh>@clean examples/Layer_function_brightness.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206123755.12"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206123756.1"><vh>@clean examples/Layer_function_color.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206123756.2"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206123756.3"><vh>@clean examples/Layer_function_contrast.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206123756.4"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206123757.1"><vh>@clean examples/Layer_function_deform.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206123757.2"><vh>Content</vh></v>
</v>
<v t="karstenw.20230313131659.1"><vh>@clean examples/Layer_function_distort_extend.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20230313131723.1"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206124323.1"><vh>@clean examples/Layer_function_difference.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206124323.2"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206124348.1"><vh>@clean examples/Layer_function_equalize.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206124348.2"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206124349.1"><vh>@clean examples/Layer_function_flip.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206124349.2"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206124349.3"><vh>@clean examples/Layer_function_hue.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206124349.4"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206124350.1"><vh>@clean examples/Layer_function_mask.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206124350.2"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206124350.3"><vh>@clean examples/Layer_function_multiply.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206124350.4"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206124350.5"><vh>@clean examples/Layer_function_opacity.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206124350.6"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206124351.1"><vh>@clean examples/Layer_function_overlay.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206124351.2"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206124351.3"><vh>@clean examples/Layer_function_posterize.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206124351.4"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206124352.1"><vh>@clean examples/Layer_function_screen.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206124352.2"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206124352.3"><vh>@clean examples/Layer_function_select.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206124352.4"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206124352.5"><vh>@clean examples/Layer_function_solarize.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206124352.6"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206124353.1"><vh>@clean examples/Layer_function_subtract_modulo.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206124353.2"><vh>Content</vh></v>
</v>
<v t="karstenw.20211206124353.3"><vh>@clean examples/Layer_function_subtract.py</vh>
<v t="karstenw.20211206131524.1"></v>
<v t="karstenw.20211206124353.4"><vh>Content</vh></v>
</v>
</v>
</v>
</vnodes>
<tnodes>
<t tx="karstenw.20170709210040.1">@language python
@tabwidth -4
@others
</t>
<t tx="karstenw.20170709210125.1"># PhotoBot 0.8 beta - last updated for NodeBox 1rc4
# Author: Tom De Smedt <tomdesmedt@trapdoor.be>
# Manual: http://nodebox.net/code/index.php/PhotoBot
# Copyright (c) 2006 by Tom De Smedt.
# Refer to the "Use" section on http://nodebox.net/code/index.php/Use
from __future__ import print_function
ALL = ['canvas', 'Layers', 'Layer', 'invertimage', 'cropimage',
'aspectRatio', 'normalizeOrientationImage', 'insetRect',
'cropImageToRatioHorizontal', 'scaleLayerToHeight', 'placeImage',
'resizeImage', 'hashFromString', 'makeunicode', 'datestring',
'label' ]
import sys
import os
import random
import math
sqrt = math.sqrt
pow = math.pow
sin = math.sin
cos = math.cos
degrees = math.degrees
radians = math.radians
asin = math.asin
import datetime
import time
import hashlib
import unicodedata
import colorsys
import io
import PIL
import PIL.ImageFilter as ImageFilter
import PIL.Image as Image
import PIL.ImageChops as ImageChops
import PIL.ImageEnhance as ImageEnhance
import PIL.ImageOps as ImageOps
import PIL.ImageDraw as ImageDraw
import PIL.ImageStat as ImageStat
import PIL.ImageFont as ImageFont
# disable large image warning
old = Image.MAX_IMAGE_PIXELS
Image.MAX_IMAGE_PIXELS = None # 200000000
# print( "MAX_IMAGE_PIXELS: %i" % old)
import pdb
import pprint
pp = pprint.pprint
kwdbg = 0
kwlog = 0
import traceback
</t>
<t tx="karstenw.20170709210125.10">def gradient(self, style=LINEAR, w=1.0, h=1.0, name="",
radius=0, radius2=0):
"""Creates a gradient layer.
Creates a gradient layer, that is usually used together
with the mask() function.
All the image functions work on gradients, so they can
easily be flipped, rotated, scaled, inverted, made brighter
or darker, ...
Styles for gradients are LINEAR, RADIAL, DIAMOND, SCATTER,
SINE, COSINE and ROUNDRECT
"""
<< init >>
img = None
<< one Image gradients >>
<< quad gradient >>
<< roundrect gradient >>
</t>
<t tx="karstenw.20170709210125.11">def merge(self, layers):
"""Flattens the given layers on the canvas.
Merges the given layers with the indices in the list
on the bottom layer in the list.
The other layers are discarded.
"""
layers.sort()
if layers[0] == 0:
del layers[0]
self.flatten(layers)
</t>
<t tx="karstenw.20170709210125.12">def flatten(self, layers=[]):
"""Flattens all layers according to their blend modes.
Merges all layers to the canvas, using the
blend mode and opacity defined for each layer.
Once flattened, the stack of layers is emptied except
for the transparent background (bottom layer).
"""
# When the layers argument is omitted,
# flattens all the layers on the canvas.
# When given, merges the indexed layers.
# Layers that fall outside of the canvas are cropped:
# this should be fixed by merging to a transparent background
# large enough to hold all the given layers' data
# (=time consuming).
if kwlog:
start = time.time()
if layers == []:
layers = xrange(1, len(self.layers))
background = self.layers._get_bg()
background.name = "Background"
for i in layers:
layer = self.layers[i]
# Determine which portion of the canvas
# needs to be updated with the overlaying layer.
x = max(0, layer.x)
y = max(0, layer.y)
w = min(background.w, layer.x+layer.w)
h = min(background.h, layer.y+layer.h)
if x > w:
#pdb.set_trace()
#print( (x, y, w, h) )
continue
if y > h:
#pdb.set_trace()
#print( (x, y, w, h) )
continue
baseimage = background.img.crop( (x, y, w, h) )
# Determine which piece of the layer
# falls within the canvas.
x = max(0, -layer.x)
y = max(0, -layer.y)
w -= layer.x
h -= layer.y
blendimage = layer.img.crop( (x, y, w, h) )
lblend = blendimage.convert("L")
bwblend = lblend.convert("1")
# Buffer layer blend modes:
# the base below is a flattened version
# of all the layers below this one,
# on which to merge this blended layer.
if layer.blend == NORMAL:
buffimage = blendimage
elif layer.blend == MULTIPLY:
buffimage = ImageChops.multiply(baseimage, blendimage)
elif layer.blend == SCREEN:
buffimage = ImageChops.screen(baseimage, blendimage)
elif layer.blend == OVERLAY:
buffimage = Blend().overlay(baseimage, blendimage)
elif layer.blend == HUE:
buffimage = Blend().hue(baseimage, blendimage)
elif layer.blend == COLOR:
buffimage = Blend().color(baseimage, blendimage)
elif layer.blend == ADD:
buffimage = ImageChops.add(baseimage, blendimage)
elif layer.blend == SUBTRACT:
img1 = baseimage.convert("RGB")
img2 = blendimage.convert("RGB")
buffimage = ImageChops.subtract(img1, img2)
buffimage = buffimage.convert("RGBA")
del img1, img2
# buffimage = ImageChops.subtract(baseimage, blendimage)
# buffimage = Blend().subtract(baseimage, blendimage)
elif layer.blend == ADD_MODULO:
buffimage = ImageChops.add_modulo(baseimage, blendimage)
elif layer.blend == SUBTRACT_MODULO:
buffimage = Blend().subtract_modulo(baseimage, blendimage)
elif layer.blend == DIFFERENCE:
# buffimage = ImageChops.difference(baseimage, blendimage)
img1 = baseimage.convert("RGB")
img2 = blendimage.convert("RGB")
buffimage = ImageChops.difference(img1, img2)
buffimage = buffimage.convert("RGBA")
del img1, img2
# Buffer a merge between the base and blend
# according to the blend's alpha channel:
# the base shines through where the blend is less opaque.
# Merging the first layer to the transparent canvas
# works slightly different than the other layers.
# buffalpha = buffimage.split()[3]
buffalpha = buffimage.getchannel("A")
basealpha = baseimage.getchannel("A")
if i == 1:
buffimage = Image.composite(baseimage, buffimage, basealpha)
else:
buffimage = Image.composite(buffimage, baseimage, buffalpha)
# The alpha channel becomes a composite of this layer and the base:
# the base's (optional) tranparent background
# is retained in arrays where the blend layer
# is transparent as well.
buffalpha = ImageChops.lighter(buffalpha, basealpha) #baseimage.split()[3])
try:
buffimage.putalpha(buffalpha)
except Exception as err:
if kwdbg and 0:
pass
# pdb.set_trace()
# TBD This needs fixing
print("PILLOW ERROR:", err)
# Apply the layer's opacity,
# merging the buff to the base with
# the given layer opacity.
baseimage = Image.blend(baseimage, buffimage, layer.alpha)
# Merge the base to the flattened canvas.
x = max(0, int( round( layer.x )) )
y = max(0, int( round( layer.y )) )
background.img.paste(baseimage, (x,y) )
del baseimage, buffimage, buffalpha, basealpha, blendimage
layers = list(layers)
layers.reverse()
for i in layers:
del self.layers[i].img
del self.layers[i]
img = Image.new("RGBA", (self.w,self.h), (255,255,255,0))
self.layers._set_bg( Layer(self, img, 0, 0, name="_bg") )
if len(self.layers) == 1:
self.layers.append(background)
else:
self.layers.insert(layers[-1], background)
del img
if kwlog:
stop = time.time()
print("Canvas.flatten( %s ) in %.3fsec." % (repr(layers), stop-start))
</t>
<t tx="karstenw.20170709210125.13">
def export(self, name, ext=".png", format="PNG", unique=False):
"""Exports the flattened canvas.
Flattens the canvas.
PNG retains the alpha channel information.
Other possibilities are JPEG and GIF.
"""
start = time.time()
<<init>>
if kwdbg and 0:
<<debug>>
self.flatten()
if format in ("JPEG",):
if self.layers[1].img.mode == "RGBA":
self.layers[1].img = self.layers[1].img.convert("RGB")
self.layers[1].img.save(path, format=format, optimize=False)
if kwlog:
print( "export() %s" % path.encode("utf-8") )
if kwlog:
stop = time.time()
print("Canvas.export(%s) in %.3f sec." % (name, stop-start))
return path
</t>
<t tx="karstenw.20170709210125.14">def draw(self, x=0, y=0, name="", ext=".png", format='PNG'):
"""Places the flattened canvas in NodeBox.
Exports to a temporary PNG file.
# Draws the PNG in NodeBox using the image() command.
# Removes the temporary file.
"""
#if not name:
# name = "photobot_" + datestring()
#if not ext:
# ext = ".png"
#folder = os.path.abspath( os.curdir )
#folder = os.path.join( folder, "exports" )
#if not os.path.exists( folder ):
# try:
# os.makedirs( folder )
# except:
# pass
try:
#filename = os.path.join( folder, name + ext )
#filename = os.path.abspath(filename)
# path = self.export(filename)
path = self.export(name, ext, format)
try:
#if nodeboxlib:
_ctx.image(path, x, y)
except NameError as err:
pass
if 0:
os.unlink( path )
return path
except Exception as err:
print(err)
print()
exc_type, exc_value, exc_tb = sys.exc_info()
traceback.print_exception(exc_type, exc_value, exc_tb)
print()
</t>
<t tx="karstenw.20170709210125.15">def preferences(self, interpolation=INTERPOLATION):
"""Settings that influence image manipulation.
Currently, only defines the image interpolation, which
can be set to NEAREST, BICUBIC, BILINEAR or LANCZOS.
"""
self.interpolation = interpolation
</t>
<t tx="karstenw.20170709210125.17">class Layers(list):
"""Extends the canvas.layers[] list so it indexes layers names.
When the index is an integer, returns the layer at that index.
When the index is a string, returns the first layer with that name.
The first element, canvas.layers[0],
is the transparent background and must remain untouched.
"""
@others
</t>
<t tx="karstenw.20170709210125.18">def __getitem__(self, index):
if type(index) in (int, long):
return list.__getitem__(self, index)
elif type(index) in (pstr, punicode):
for layer in self:
if layer.name == index:
return layer
return None
</t>
<t tx="karstenw.20170709210125.19">def _get_bg(self):
return list.__getitem__(self, 0)
</t>
<t tx="karstenw.20170709210125.20">def _set_bg(self, layer):
list.__setitem__(self, 0, layer)
</t>
<t tx="karstenw.20170709210125.21">class Layer:
"""Implements a layer on the canvas.
A canvas layer stores an image at a given position on the canvas,
and all the Photoshop transformations possible for this layer:
duplicate(), desature(), overlay(), rotate(), and so on.
"""
@others
</t>
<t tx="karstenw.20170709210125.22">def __init__(self, canvas, img, x=0, y=0, name=""):
self.canvas = canvas
self.name = name
self.img = img
self.x = x
self.y = y
self.w = img.size[0]
self.h = img.size[1]
self.alpha = 1.0
self.blend = NORMAL
self.pixels = Pixels(self.img, self)
</t>
<t tx="karstenw.20170709210125.23">def prnt(self):
# for debugging
print("-" * 20)
print( "name: '%s' " % self.name.encode("utf-8") )
print("xy: %i %i" % (self.x, self.y) )
print("wh: %i %i" % (self.w, self.h) )
print("alpha: %.2f" % float(self.alpha) )
print("blend: %s" % str(self.blend) )
print("-" * 20)
</t>
<t tx="karstenw.20170709210125.24">def index(self):
"""Returns this layer's index in the canvas.layers[].
Searches the position of this layer in the canvas'
layers list, return None when not found.
"""
for i in xrange(len(self.canvas.layers)):
if self.canvas.layers[i] == self:
break
if self.canvas.layers[i] == self:
return i
else:
return None
</t>
<t tx="karstenw.20170709210125.25">def copy(self):
"""Returns a copy of the layer.
This is different from the duplicate() method,
which duplicates the layer as a new layer on the canvas.
The copy() method returns a copy of the layer
that can be added to a different canvas.
"""
layer = Layer(None, self.img.copy(), self.x, self.y, self.name)
layer.w = self.w
layer.h = self.h
layer.alpha = self.alpha
layer.blend = self.blend
return layer
</t>
<t tx="karstenw.20170709210125.26">def delete(self):
"""Removes this layer from the canvas.
"""
i = self.index()
if i != None:
del self.canvas.layers[i]
</t>
<t tx="karstenw.20170709210125.27">def up(self):
"""Moves the layer up in the stacking order.
"""
i = self.index()
if i != None:
del self.canvas.layers[i]
i = min(len(self.canvas.layers), i+1)
self.canvas.layers.insert(i, self)
</t>
<t tx="karstenw.20170709210125.28">def down(self):
"""Moves the layer down in the stacking order.
"""
i = self.index()
if i != None:
del self.canvas.layers[i]
i = max(0, i-1)
self.canvas.layers.insert(i, self)
</t>
<t tx="karstenw.20170709210125.29">def bounds(self):
"""Returns the size of the layer.
This is the width and height of the bounding box,
the invisible rectangle around the layer.
"""
return self.img.size
</t>
<t tx="karstenw.20170709210125.30">def select(self, path, feather=True):
"""Applies the polygonal lasso tool on a layer.
The path paramater is a list of points,
either [x1, y1, x2, y2, x3, y3, ...]
or [(x1,y1), (x2,y2), (x3,y3), ...]
The parts of the layer that fall outside
this polygonal area are cut.
The selection is not anti-aliased,
but the feather parameter creates soft edges.
"""
w, h = self.img.size
mask = Image.new("L", (w,h), 0)
draw = ImageDraw.Draw(mask)
draw.polygon(path, fill=255)
if feather:
mask = mask.filter(ImageFilter.SMOOTH_MORE)
mask = mask.filter(ImageFilter.SMOOTH_MORE)
mask = ImageChops.darker(mask, self.img.getchannel("A")) #self.img.split()[3])
self.img.putalpha(mask)
</t>
<t tx="karstenw.20170709210125.31">def mask(self):
"""Masks the layer below with this layer.
Commits the current layer to the alpha channel of
the previous layer. Primarily, mask() is useful when
using gradient layers as masks on images below.
For example:
canvas.layer("image.jpg")
canvas.gradient()
canvas.layer(2).flip()
canvas.layer(2).mask()
Adds a white-to-black linear gradient to
the alpha channel of image.jpg,
making it evolve from opaque on
the left to transparent on the right.
"""
if len(self.canvas.layers) < 2:
return
i = self.index()
if i == 0:
return