entry #1
comments 2
fuckyou.jpg JPEG image data, Exif standard: [TIFF image data, big-endian, direntries=5, width=759, height=582, orientation=upper-left, datetime=2026:06:02 19:09:38], baseline, precision 8, 759x582, components 3

started at ; stage 2 since . guess by
I've been trying to sleep better lately, so can you help me filter blue light? submissions may be written in any language.
the blue light spectrum is a strong signal to the human body that it is currently daytime, and it significantly impacts the circadian rhythm and melatonin production. it is thus a common desire to decrease one's exposure to it at night, especially if one already has sleep issues. as computer screens (along with white lightbulbs) are among the biggest household sources of blue light at night, a class of software exists to filter out blue and shift the colours displayed on the screen to warmer tones with more red.
filtering the whole screen is a bit much, so I won't ask you to do that. starting simple is always best, so let's just do one image. there are multiple ways to interpret "filtering out blue" and multiple ways to go about it. I will briefly go over one; however, this problem is open-ended and any solution is admissible.
colour temperature is a parameter based on the colour of light emitted by an idealized black body at a certain temperature, usually given in Kelvin. 1,000K is quite red, while 10,000K is quite blue. the path the colour takes as the temperature changes is called the Planckian locus. with a lookup table or approximation of this locus, you can find the corresponding colour to a temperature in a colour space such as sRGB. once you take the difference between a "reference" like 6,500K (the D65 standard used by sRGB; 6,500K corresponds to rgb(1.0, 1.0, 1.0)) and a warmer "target" like 2,400K, you can now add that difference to any colour to get an equivalent calibrated for a warmer white point. (actual blue light filter software uses the difference to compute gamma settings for each channel for the same effect.)
your challenge, given an image, is to return the same image with less blue in it. it is not acceptable to return an image with more blue in it. as any language is allowed, there is no fixed API.
you can download all the entries
comments 2
fuckyou.jpg JPEG image data, Exif standard: [TIFF image data, big-endian, direntries=5, width=759, height=582, orientation=upper-left, datetime=2026:06:02 19:09:38], baseline, precision 8, 759x582, components 3

comments 0
post a comment
dir cg101
dir src
main.rs ASCII text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::env::args;
use image::{GenericImageView as _, ImageBuffer, Rgb};
fn main() {
let path = args().nth(1).unwrap();
let img = image::open(&path).expect("failed to open image");
let (w, h) = img.dimensions();
let mut out = ImageBuffer::new(w, h);
for (x, y, p) in img.pixels() {
out.put_pixel(x, y, Rgb([p[0], p[1], p[2] / 2]));
}
out.save("blueless.png").expect("failed to save image");
println!("done");
}
Cargo.lock ASCII text
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
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "adler2"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]]
name = "aligned"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee4508988c62edf04abd8d92897fca0c2995d907ce1dfeaf369dac3716a40685"
dependencies = [
"as-slice",
]
[[package]]
name = "aligned-vec"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc890384c8602f339876ded803c97ad529f3842aba97f6392b3dba0dd171769b"
dependencies = [
"equator",
]
[[package]]
name = "anyhow"
version = "1.0.102"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
[[package]]
name = "arbitrary"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1"
[[package]]
name = "arg_enum_proc_macro"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "arrayvec"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
[[package]]
name = "as-slice"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "516b6b4f0e40d50dcda9365d53964ec74560ad4284da2e7fc97122cd83174516"
dependencies = [
"stable_deref_trait",
]
[[package]]
name = "autocfg"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
[[package]]
name = "av-scenechange"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f321d77c20e19b92c39e7471cf986812cbb46659d2af674adc4331ef3f18394"
dependencies = [
"aligned",
"anyhow",
"arg_enum_proc_macro",
"arrayvec",
"log",
"num-rational",
"num-traits",
"pastey",
"rayon",
"thiserror",
"v_frame",
"y4m",
]
[[package]]
name = "av1-grain"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cfddb07216410377231960af4fcab838eaa12e013417781b78bd95ee22077f8"
dependencies = [
"anyhow",
"arrayvec",
"log",
"nom",
"num-rational",
"v_frame",
]
[[package]]
name = "avif-serialize"
version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7178fe5f7d460b13895ebb9dcb28a3a6216d2df2574a0806cb51b555d297f38"
dependencies = [
"arrayvec",
]
[[package]]
name = "bit_field"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6"
[[package]]
name = "bitflags"
version = "2.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3"
[[package]]
name = "bitstream-io"
version = "4.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7eff00be299a18769011411c9def0d827e8f2d7bf0c3dbf53633147a8867fd1f"
dependencies = [
"no_std_io2",
]
[[package]]
name = "built"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c0e531d93d39c34eef561e929e8a7f86d77a5af08aac4f6d6e39976c51858e9"
[[package]]
name = "bumpalo"
version = "3.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
[[package]]
name = "bytemuck"
version = "1.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8efb64bd706a16a1bdde310ae86b351e4d21550d98d056f22f8a7f7a2183fec"
[[package]]
name = "byteorder-lite"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
[[package]]
name = "cc"
version = "1.2.62"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1dce859f0832a7d088c4f1119888ab94ef4b5d6795d1ce05afb7fe159d79f98"
dependencies = [
"find-msvc-tools",
"jobserver",
"libc",
"shlex",
]
[[package]]
name = "cfg-if"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]]
name = "cg101"
version = "0.1.0"
dependencies = [
"image",
]
[[package]]
name = "color_quant"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]]
name = "crc32fast"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"
dependencies = [
"cfg-if",
]
[[package]]
name = "crossbeam-deque"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
[[package]]
name = "crunchy"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
[[package]]
name = "either"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e"
[[package]]
name = "equator"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4711b213838dfee0117e3be6ac926007d7f433d7bbe33595975d4190cb07e6fc"
dependencies = [
"equator-macro",
]
[[package]]
name = "equator-macro"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "exr"
version = "1.74.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4300e043a56aa2cb633c01af81ca8f699a321879a7854d3896a0ba89056363be"
dependencies = [
"bit_field",
"half",
"lebe",
"miniz_oxide",
"rayon-core",
"smallvec",
"zune-inflate",
]
[[package]]
name = "fax"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caf1079563223d5d59d83c85886a56e586cfd5c1a26292e971a0fa266531ac5a"
[[package]]
name = "fdeflate"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c"
dependencies = [
"simd-adler32",
]
[[package]]
name = "find-msvc-tools"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
[[package]]
name = "flate2"
version = "1.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c"
dependencies = [
"crc32fast",
"miniz_oxide",
]
[[package]]
name = "getrandom"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
dependencies = [
"cfg-if",
"libc",
"r-efi",
"wasip2",
]
[[package]]
name = "gif"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee8cfcc411d9adbbaba82fb72661cc1bcca13e8bba98b364e62b2dba8f960159"
dependencies = [
"color_quant",
"weezl",
]
[[package]]
name = "half"
version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b"
dependencies = [
"cfg-if",
"crunchy",
"zerocopy",
]
[[package]]
name = "image"
version = "0.25.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104"
dependencies = [
"bytemuck",
"byteorder-lite",
"color_quant",
"exr",
"gif",
"image-webp",
"moxcms",
"num-traits",
"png",
"qoi",
"ravif",
"rayon",
"rgb",
"tiff",
"zune-core",
"zune-jpeg",
]
[[package]]
name = "image-webp"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3"
dependencies = [
"byteorder-lite",
"quick-error",
]
[[package]]
name = "imgref"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40fac9d56ed6437b198fddba683305e8e2d651aa42647f00f5ae542e7f5c94a2"
[[package]]
name = "interpolate_name"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "itertools"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285"
dependencies = [
"either",
]
[[package]]
name = "jobserver"
version = "0.1.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33"
dependencies = [
"getrandom",
"libc",
]
[[package]]
name = "lebe"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8"
[[package]]
name = "libc"
version = "0.2.186"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
[[package]]
name = "libfuzzer-sys"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f12a681b7dd8ce12bff52488013ba614b869148d54dd79836ab85aafdd53f08d"
dependencies = [
"arbitrary",
"cc",
]
[[package]]
name = "log"
version = "0.4.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
[[package]]
name = "loop9"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062"
dependencies = [
"imgref",
]
[[package]]
name = "maybe-rayon"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519"
dependencies = [
"cfg-if",
"rayon",
]
[[package]]
name = "memchr"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
[[package]]
name = "miniz_oxide"
version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
dependencies = [
"adler2",
"simd-adler32",
]
[[package]]
name = "moxcms"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b"
dependencies = [
"num-traits",
"pxfm",
]
[[package]]
name = "new_debug_unreachable"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
[[package]]
name = "no_std_io2"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418abd1b6d34fbf6cae440dc874771b0525a604428704c76e48b29a5e67b8003"
dependencies = [
"memchr",
]
[[package]]
name = "nom"
version = "8.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
dependencies = [
"memchr",
]
[[package]]
name = "noop_proc_macro"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8"
[[package]]
name = "num-bigint"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9"
dependencies = [
"num-integer",
"num-traits",
]
[[package]]
name = "num-derive"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "num-integer"
version = "0.1.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
dependencies = [
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
dependencies = [
"num-bigint",
"num-integer",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
]
[[package]]
name = "once_cell"
version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "paste"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "pastey"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35fb2e5f958ec131621fdd531e9fc186ed768cbe395337403ae56c17a74c68ec"
[[package]]
name = "png"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61"
dependencies = [
"bitflags",
"crc32fast",
"fdeflate",
"flate2",
"miniz_oxide",
]
[[package]]
name = "ppv-lite86"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
dependencies = [
"zerocopy",
]
[[package]]
name = "proc-macro2"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
dependencies = [
"unicode-ident",
]
[[package]]
name = "profiling"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d595e54a326bc53c1c197b32d295e14b169e3cfeaa8dc82b529f947fba6bcf5"
dependencies = [
"profiling-procmacros",
]
[[package]]
name = "profiling-procmacros"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4488a4a36b9a4ba6b9334a32a39971f77c1436ec82c38707bce707699cc3bbcb"
dependencies = [
"quote",
"syn",
]
[[package]]
name = "pxfm"
version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0c5ccf5294c6ccd63a74f1565028353830a9c2f5eb0c682c355c471726a6e3f"
[[package]]
name = "qoi"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001"
dependencies = [
"bytemuck",
]
[[package]]
name = "quick-error"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
[[package]]
name = "quote"
version = "1.0.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
dependencies = [
"proc-macro2",
]
[[package]]
name = "r-efi"
version = "5.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
[[package]]
name = "rand"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea"
dependencies = [
"rand_chacha",
"rand_core",
]
[[package]]
name = "rand_chacha"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
dependencies = [
"ppv-lite86",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
dependencies = [
"getrandom",
]
[[package]]
name = "rav1e"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43b6dd56e85d9483277cde964fd1bdb0428de4fec5ebba7540995639a21cb32b"
dependencies = [
"aligned-vec",
"arbitrary",
"arg_enum_proc_macro",
"arrayvec",
"av-scenechange",
"av1-grain",
"bitstream-io",
"built",
"cfg-if",
"interpolate_name",
"itertools",
"libc",
"libfuzzer-sys",
"log",
"maybe-rayon",
"new_debug_unreachable",
"noop_proc_macro",
"num-derive",
"num-traits",
"paste",
"profiling",
"rand",
"rand_chacha",
"simd_helpers",
"thiserror",
"v_frame",
"wasm-bindgen",
]
[[package]]
name = "ravif"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e52310197d971b0f5be7fe6b57530dcd27beb35c1b013f29d66c1ad73fbbcc45"
dependencies = [
"avif-serialize",
"imgref",
"loop9",
"quick-error",
"rav1e",
"rayon",
"rgb",
]
[[package]]
name = "rayon"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d"
dependencies = [
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"
dependencies = [
"crossbeam-deque",
"crossbeam-utils",
]
[[package]]
name = "rgb"
version = "0.8.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47b34b781b31e5d73e9fbc8689c70551fd1ade9a19e3e28cfec8580a79290cc4"
[[package]]
name = "rustversion"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "simd-adler32"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214"
[[package]]
name = "simd_helpers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6"
dependencies = [
"quote",
]
[[package]]
name = "smallvec"
version = "1.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
[[package]]
name = "stable_deref_trait"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
[[package]]
name = "syn"
version = "2.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "thiserror"
version = "2.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tiff"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b63feaf3343d35b6ca4d50483f94843803b0f51634937cc2ec519fc32232bc52"
dependencies = [
"fax",
"flate2",
"half",
"quick-error",
"weezl",
"zune-jpeg",
]
[[package]]
name = "unicode-ident"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "v_frame"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "666b7727c8875d6ab5db9533418d7c764233ac9c0cff1d469aec8fa127597be2"
dependencies = [
"aligned-vec",
"num-traits",
"wasm-bindgen",
]
[[package]]
name = "wasip2"
version = "1.0.3+wasi-0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6"
dependencies = [
"wit-bindgen",
]
[[package]]
name = "wasm-bindgen"
version = "0.2.122"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed04576f974d2b2fba0f38c51dbc5518011e38c36bf1143164be765528fd409"
dependencies = [
"cfg-if",
"once_cell",
"rustversion",
"wasm-bindgen-macro",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.122"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "916151b09da36bd82f6615cbf3a419e2f0ba23a03c6160e8e92eb6bd4aa1dec6"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.122"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "299047362ccbfce148b67ab7e73349f77748e00c8296f9542adfad2ad82c5c5e"
dependencies = [
"bumpalo",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.122"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a929b2c61f11ba3e9bc35b50c1f25cb38e0e892c0c231ae2b8cf78d5dad4437"
dependencies = [
"unicode-ident",
]
[[package]]
name = "weezl"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"
[[package]]
name = "wit-bindgen"
version = "0.57.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
[[package]]
name = "y4m"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5a4b21e1a62b67a2970e6831bc091d7b87e119e7f9791aef9702e3bef04448"
[[package]]
name = "zerocopy"
version = "0.8.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.8.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "zune-core"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb8a0807f7c01457d0379ba880ba6322660448ddebc890ce29bb64da71fb40f9"
[[package]]
name = "zune-inflate"
version = "0.2.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02"
dependencies = [
"simd-adler32",
]
[[package]]
name = "zune-jpeg"
version = "0.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296"
dependencies = [
"zune-core",
]
Cargo.toml ASCII text
1
2
3
4
5
6
7
[package]
name = "cg101"
version = "0.1.0"
edition = "2024"
[dependencies]
image = "0.25.10"
comments 0
post a comment
i miss python 2.py ASCII text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import sys
from PIL import Image
def fix(filename):
image = Image.open(filename).convert("RGBA")
pixels = image.load()
width, height = image.size
for y in xrange(height):
for x in xrange(width):
colors = pixels[x,y]
pixels[x,y] = (colors[0], colors[1], 0, colors[3])
image.save(filename + "_fixed.png")
print "done"
if __name__ == "__main__":
fix(sys.argv[1])
comments 0
post a comment
dir 101
blight.m ASCII text
1
2
3
4
5
[six,seven] = imread("bluey_.png")
if(isempty(seven)) bluey = six else bluey = ind2rgb(six,seven) endif
bluey(:,:,3) = zeros(size(bluey)(1),size(bluey)(2))
imshow(bluey)
# the bluey
bluey_.png JPEG image data, JFIF standard 1.01, resolution (DPI), density 150x150, segment length 16, baseline, precision 8, 630x350, components 3

oldbluey_.png JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 275x183, components 3

pp.png PNG image data, 225 x 225, 8-bit colormap, non-interlaced

comments 0
post a comment
yellow.sh ASCII text
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
#!/bin/sh
#
# WARNING :: BAD perfromance Sorry
#
#
#
# STDIN = Image (Blue)
# STDOUT = Image Sans (
#
# ##################
# #### ####
# ## ##
# ## ##
# ## ##
# ## ###### ##
# ## ###### ##
# ## ###### ## ###### ##
# ## ###### ##
# #### ## ## ####
# ## ###################### ##
# ## ## ## ## ## ## ##
# #### ############## ####
# ########## ##########
# ## ############################## ##
# #### ## ## ## ## ## ####
# ## ## ###### ###### ## ##
# ## #### ###### ## ###### #### ##
# ## ## ## ## ## ##
# ## ## ## ## ## ##
# ## ## #### #### ## ##
# #### ## ## ## ## ####
# ###### ############## ######
# #### ############## ####
# ##################################
# ################ ################
# ############ ############
# ###### ## ## ######
# ## #### #### ##
# ########## ##########
#
# ) Blue
#
take() {
_v="$(dd status=none bs="$1" count=1)"
test -n "$_v" || return 1
printf '%s' "$_v";
}
hex() {
od -An -tx1 | tr -d ' \n'
}
unhex() {
while true; do
_vv="$(take 2)" || break
printf '\x'"$_vv"
done
}
if command -v xxd >/dev/null 2>&1; then
hex() {
xxd -p | tr -d ' \n'
}
unhex() {
xxd -p -r
}
fi
if test -z "$(printf 'a\nna' | (read -N4 v; cat) 2>/dev/null)"; then
take() {
read -N$(($1 + 0)) _v
test -n "$_v" || return 1
printf '%s' "$_v"
}
fi
(
(
ffmpeg \
-i - \
-f rawvideo \
-pix_fmt rgba \
-y - \
3>&1 4>&2 2>&3 1>&4
) |
grep -Em1 Video: |
grep -Eom1 '[0-9][0-9]*x[0-9][0-9]*'
) 2>&1 | (
read size
echo $size
pxs=$(eval 'echo $(('"$(echo $size | tr 'x' '*')"'))')
i=0
p_a=1000
p_b=1000
hex | while :; do
take 4 || break
take 2 >/dev/null || break
printf '00'
take 2 || break
i=$(($i + 1))
p_a=$(($i * 100 / $pxs))
if test -t 2 && test $p_a -ne $p_b; then
p_b=$p_a;
printf '\r%s%%' "$p_a" >&2;
fi
done
if test -t 2; then
printf '\n' >&2
fi
) | (
read size
unhex | ffmpeg \
-f rawvideo \
-pixel_format rgba \
-video_size $size \
-i - \
-f apng \
-y - \
2>/dev/null
)
comments 0
post a comment
101.ua Unicode text, UTF-8 text, with no line terminators
1°img &frab "download.png"
comments 0
post a comment
blue_light.ec Unicode text, UTF-8 text
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
? Written and tested on a little endian system
? Good luck porting it to big endian
? May take some time to fully execute
"io.ec"
"utilities.ec"
"bmp.ec"
+--E ? Discard file length
>-⎚-⬟-r |
+-⛁-+ ? Sign correction
|
+-⌂-b ? Check signature and move file size backwards, we'll need that
F-b
F-b
F-b
F-⛩-+ ? Check reserved
|
+f#fB ? Move offset to the right and construct it at the same time
B
+f#f
OⓄ#MM
A
*
B
B
Of#f-+
|
+Ⓞ#M#MM
A
*
B
B
Of#f-+
|
+Ⓞ#M##MMM
A
bbb
|
+F
|
O ? Check and validate some important bytes, otherwise skip to the data section
I
I
I +-⁖-O ? Bits per pixel should be 24
# I I
I I I
+-M-+ #M# #--f-+
I $ B
I | S
+M+ #-+-#
[ ]
+⚠ EfB
o |
| ? Compression should be zero
#-+-#
[ ]
+⚠ +-f-B
o f-B
f-B
f-B
B
f-O ? Move offset value, subtract 34 from it
I
I
I +MD-+ +--------+
I I $ | B
I I S U B
#-+ +--⁖}--+ +4ff-+
| B ? Apply blue light filter
+-+-+ +-5ff-B
( ) B
| +-8ff-B
+F
|
+F
|
+R
U
+{---+
B |
+-+-+ |
( ) |
O-F +-f+
O ? Construct reserved part
O
O +-fff-+ +-fff-+
B B B B O
B B B B I
B B B B I
+-fff-+ +-fff-+ I
I
+-+ #--+ I
I I | I I
I I +b I I
I OfB | +-#
I +-MF I
+M+ I
|
+-O
|
OⓄO©DM#DDD##⦵DDD+
|
$
O---------------+
I
I
I
OⓄMDD+
$
+-©D#
I
#DDDDD#
I
I
I
I
#
I
#DDDDDDw-OD+
$
W
bmp.ec Unicode text, UTF-8 text
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
"utilities.ec"
"io.ec"
? Check signature
? Error and exit if signature does not match
+-⌂-O
| I+M#fB
| II S
| II #-+-#
++ II ] [
| II E +-⚠
E II +-+ o
| #+ +F
| +-b
| +⚠ A O
] [o * * I
#+# S I I
+---+ I I
+M#
? Check reserved
+-⛩-+
| |
| +-#-+
| [ ]
| +⚠ |
| o |
| +-#-+
| [ ]
| +⚠ |
| |o |
] [ +-#-+
+-+-+ ] [
#---+ +⚠
o
? Move N numbers to the next stack where N is the top-most item
+-⁖---+
| U
| +{--+
| | |
| #-+-# |
| ] [ |
+---E $ D
f-B
? Divide by 255
+-◲-+
| |
| +-OⓄ#MD-+
| $
+-----------Q
? Multiply by 255
+-⧉-OⓄ#MD
| |
+---M---+
? Gamma correction approximation
? x**2.2 ≈ max(0, -0.1099x+1.0989x**2)
+-γ-#O©+
| I +-MMDO©+
| I I I
| ##+ I
+{OE ###MMM+
n | |
l +L +-MMM### $
| | $ | +-M-Q
#-+-# Q +©+ $
S I I O-#
+-MM+ I |
OD+ +©+
S I
| I
+MM###
? Manipulate blue channel
+-8-◲-O
| I
+--+ I
| ##
| I
| ####M+
+γ⧉+ I
| I
| OMMMMM+
| I
| Q
| O
+--M+ I ? Multiply with magic constant, 2/9-1/1187. (Approximates 0.22137978)
S I
Q #
$ I
+M#
? Manipulate green channel
+-5-◲-O
| I +-+
+--+ I I $
| I I Q
| #-+ O
| +-ⓄDD#
+γ⧉+ D
| A D
+---M--* *Q D ? Multiply with magic constant, 3/5+1/138. (Approximates 0.60724493)
I D
ODDM-+
? Manipulate red channel, only do gamma correction
+-4--+
| |
+-◲γ⧉+
io.ec Unicode text, UTF-8 text
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
"utilities.ec"
? Print "Enter filename: "
+-⎚-O
| I +-P-O +-P-#
| I | I I D
+P+ I I I I D
| I A # I D
MM+ #-###MM I +-M-# I D
| I I | I D
+MM I | | I D
# +-M# #-P D-DDP-+
# I
# +MM### I
# | I +-P-+ I
I | I I D I
I S # I $ #-PO
| S I I +-P-# I
OP-+ I I I O#P+ +-+ I
O-P-+ I I | I I ####MMMMPDDDD#DDD
I I #PD-P I |
S I +----P# +-P#DDD#DD+
$ I | $
| | +-+
+-M-#
? Filename read loop, terminates if the input is equal to 0 (EOF)
+-⬟----+
| | +--+
+E U U |
| +++ |
+R | |
| &-+ |
| | [
| #-+-#
| ]
+{-E----+
? Print newline, useful for debugging
+-⏎-O
| I
| I
PM+ #
| I
I I
+-+
? Print "Invalid file"
+-+
| ⚠-O
| I #MMDD#P-O #MM+ A
| I I I I I * *
| I I I I I I #-P-##©P-ⓣ+
| #-+ #-+ I I I
| +P# +-+ I
+PM+ I I I
I I I I +PDDDP##DDP-+
I O-P+ I I |
I I DP+ +-#P# +⦵#PO
+-# I I
I I
+PMMMM####
lenna.bmp PC bitmap, Windows 98/2000 and newer format, 512 x 512 x 24, cbSize 786570, bits offset 138

utilities.ec Unicode text, UTF-8 text
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
? Sign corrects the entire stack
? Pushes a -1 to the next stack first.
? Then goes back, loops through every item on the stack, adds 256 if the number is negative,
? and moves them to the next stack
? Finally moves everything back until it hits a -1 and pops it off
? Should work correctly if the stack contains bytes read from a file
? Otherwise you may end up in situations you wouldn't want to be in
+-⛁-FODO
| I
| I
| #######MMMMMMMB
| U
+{--------------+ +{-----+
| | |
+-+ E +-+-+ |
| [ ] ( ) |
| +-+-+ | #-+-# |
| # | | | |
| A EF +L | |
| * | | l |
| I | b#F | B
| O | A U $
F-}+b# | *--}+f-+
n |
+----+
? Add 8 to the number on top of the stack
*-©-O
\ I
\ I
\##MM+
\ |
\ A
**
? Add 16 to the number on top of the stack
*-Ⓞ-O
\ I
\ I
\###MMM*
\ A
*---*
? Subtract 8 from the number on top of the stack
*-⦵-O
\ I
\ I
\##MM+
\ $
\ S
*-+
? Subtract 16 from the number on top of the stack
*-ⓣ-O
\ I
\ I
\###MMM+
\ $
\ S
*---+
comments 0
post a comment
remBLUE.m ASCII text
1
2
3
4
function out = remBLUE(mat)
mat(:, :, 3) = 0;
out = mat;
endfunction
comments 0
post a comment
main.rs ASCII text
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
//! Takes sRGB PPM files as input
//! I know PPM isn't sRGB according to the spec
//! But even in the spec they mention putting sRGB data in
//! So fuck the spec it assumes sRGB
//! Usage: input output [target temperature] [source temperature]
//! Default target is 4000K, default source is 6500K
//! Temperatures are in Kelvin
//! Not much output apart from that. It's a tad slow but does its job.
use std::env::Args;
use std::error::Error;
use std::fs::File;
use std::io;
use std::io::BufReader;
use std::io::BufWriter;
use std::io::ErrorKind;
use std::io::prelude::*;
use std::path::Path;
use std::str::FromStr;
/// Second radiation constant
/// Source: https://en.wikipedia.org/wiki/Planckian_locus#International_Temperature_Scale
const C_2: f64 = 1.438_776_877;
/// Adapting luminance
/// https://en.wikipedia.org/wiki/CIECAM02#Parameter_decision_table
/// https://en.wikipedia.org/wiki/SRGB#Viewing_environment
const L_A: f64 = 0.20 * 80.;
/// Surround factor
const F: f64 = 1.;
#[derive(Debug)]
enum PPMRaster {
PPM8(Vec<Vec<(u8, u8, u8)>>),
PPM16(Vec<Vec<(u16, u16, u16)>>),
}
#[derive(Debug)]
struct PPM {
width: usize,
height: usize,
maxval: u16,
raster: PPMRaster,
}
impl PPM {
fn write(&self, mut file: File) -> Result<(), io::Error> {
file.write_all(&['P' as u8, '6' as u8, '\n' as u8])?;
file.write_all(self.width.to_string().as_bytes())?;
file.write_all(&[' ' as u8])?;
file.write_all(self.height.to_string().as_bytes())?;
file.write_all(&['\n' as u8])?;
file.write_all(self.maxval.to_string().as_bytes())?;
file.write_all(&['\n' as u8])?;
let mut handle: BufWriter<File> = BufWriter::with_capacity(
match self.maxval {
0..256 => self.width * 3,
_ => self.width * 6,
},
file,
);
for row in 0..self.height {
for column in 0..self.width {
match &self.raster {
PPMRaster::PPM8(pixels) => {
handle.write_all(&[
pixels[row][column].0,
pixels[row][column].1,
pixels[row][column].2,
])?;
}
PPMRaster::PPM16(pixels) => {
handle.write_all(&pixels[row][column].0.to_be_bytes())?;
handle.write_all(&pixels[row][column].1.to_be_bytes())?;
handle.write_all(&pixels[row][column].2.to_be_bytes())?;
}
}
}
}
handle.flush()?;
Ok(())
}
fn read(mut file: File) -> Result<PPM, Box<dyn Error>> {
fn read_line(file: &mut File) -> Result<Vec<char>, io::Error> {
let mut buf: Vec<char> = Vec::new();
loop {
let mut byte: [u8; 1] = Default::default();
file.read_exact(&mut byte)?;
let chr: char = byte[0] as char;
match chr {
'#' => {
while (byte[0] as char) != '\r' && (byte[0] as char) != '\n' {
match file.read_exact(&mut byte) {
Ok(_) => {}
Err(why) => match why.kind() {
ErrorKind::UnexpectedEof => {
return Ok(buf);
}
_ => {
return Err(why);
}
},
}
}
}
'\t' | '\r' | '\n' | ' ' | '\x0b' | '\x0c' => {
return Ok(buf);
}
_ => {
buf.push(chr);
}
}
}
}
fn parse_number<N: FromStr>(v: Vec<char>) -> Result<N, <N as FromStr>::Err> {
v.into_iter().collect::<String>().parse::<N>()
}
let magic_number: Vec<char> = read_line(&mut file)?;
if magic_number != vec!['P', '6'] {
return Err(format!(
"This program only supports PPM files! (magic number = {:?})",
magic_number
)
.into());
}
let width: usize = parse_number(read_line(&mut file)?)?;
let height: usize = parse_number(read_line(&mut file)?)?;
let maxval: u16 = parse_number(read_line(&mut file)?)?;
let mut raster: PPMRaster;
if maxval < 256 {
raster = PPMRaster::PPM8(Vec::with_capacity(height));
} else {
raster = PPMRaster::PPM16(Vec::with_capacity(height));
}
let mut handle: BufReader<File> = match raster {
PPMRaster::PPM8(_) => BufReader::with_capacity(width * 3, file),
PPMRaster::PPM16(_) => BufReader::with_capacity(width * 6, file),
};
for row in 0..height {
match raster {
PPMRaster::PPM8(ref mut v) => v.push(Vec::with_capacity(width)),
PPMRaster::PPM16(ref mut v) => v.push(Vec::with_capacity(width)),
}
for _ in 0..width {
match raster {
PPMRaster::PPM8(ref mut v) => {
let mut buf: [u8; 3] = Default::default();
handle.read_exact(&mut buf)?;
v[row].push((buf[0], buf[1], buf[2]));
}
PPMRaster::PPM16(ref mut v) => {
let mut buf: [u8; 6] = Default::default();
handle.read_exact(&mut buf)?;
fn to_u16(a: u8, b: u8) -> u16 {
((a as u16) << 8) | (b as u16)
}
v[row].push((
to_u16(buf[0], buf[1]),
to_u16(buf[2], buf[3]),
to_u16(buf[4], buf[5]),
));
}
}
}
}
Ok(PPM {
width,
height,
maxval,
raster,
})
}
}
impl From<&PPM> for Raster<SRgb> {
fn from(value: &PPM) -> Self {
let mut floats: Vec<Vec<SRgb>>;
match &value.raster {
PPMRaster::PPM8(v) => {
floats = Vec::with_capacity(v.len());
for row in 0..v.len() {
floats.push(Vec::with_capacity(v[row].len()));
for pixel in 0..v[row].len() {
floats[row].push(SRgb::from((
f64::from(v[row][pixel].0) / (value.maxval as f64),
f64::from(v[row][pixel].1) / (value.maxval as f64),
f64::from(v[row][pixel].2) / (value.maxval as f64),
)));
}
}
}
PPMRaster::PPM16(v) => {
floats = Vec::with_capacity(v.len());
for row in 0..v.len() {
floats.push(Vec::with_capacity(v[row].len()));
for pixel in 0..v[row].len() {
floats[row].push(SRgb::from((
f64::from(v[row][pixel].0) / (value.maxval as f64),
f64::from(v[row][pixel].1) / (value.maxval as f64),
f64::from(v[row][pixel].2) / (value.maxval as f64),
)));
}
}
}
}
Self(floats)
}
}
impl From<(&Raster<SRgb>, u16)> for PPM {
fn from(value: (&Raster<SRgb>, u16)) -> Self {
let floats: &Vec<Vec<SRgb>> = &value.0.0;
let maxval: u16 = value.1;
PPM {
width: floats[0].len(),
height: floats.len(),
maxval,
raster: match maxval {
0..256 => {
let mut integers: Vec<Vec<(u8, u8, u8)>> = Vec::with_capacity(floats.len());
for row in 0..floats.len() {
integers.push(Vec::with_capacity(floats[row].len()));
for pixel in 0..floats[row].len() {
integers[row].push((
(floats[row][pixel].r * (maxval as f64)).round() as u8,
(floats[row][pixel].g * (maxval as f64)).round() as u8,
(floats[row][pixel].b * (maxval as f64)).round() as u8,
));
}
}
PPMRaster::PPM8(integers)
}
_ => {
let mut integers: Vec<Vec<(u16, u16, u16)>> = Vec::with_capacity(floats.len());
for row in 0..floats.len() {
integers.push(Vec::with_capacity(floats[row].len()));
for pixel in 0..floats[row].len() {
integers[row].push((
(floats[row][pixel].r * (maxval as f64)).round() as u16,
(floats[row][pixel].g * (maxval as f64)).round() as u16,
(floats[row][pixel].b * (maxval as f64)).round() as u16,
));
}
}
PPMRaster::PPM16(integers)
}
},
}
}
}
macro_rules! color {
($color_space:ident { $first_component:ident , $second_component:ident , $third_component:ident }) => {
#[derive(Debug, Clone, Copy)]
struct $color_space {
$first_component: f64,
$second_component: f64,
$third_component: f64,
}
impl From<$color_space> for (f64, f64, f64) {
fn from(value: $color_space) -> Self {
(
value.$first_component,
value.$second_component,
value.$third_component,
)
}
}
impl From<(f64, f64, f64)> for $color_space {
fn from(value: (f64, f64, f64)) -> Self {
Self {
$first_component: value.0,
$second_component: value.1,
$third_component: value.2,
}
}
}
};
}
color! {Xyz { x, y, z }}
color! {Rgb { r, g, b }}
color! {SRgb { r, g, b }}
color! {Lms { l, m, s }}
#[derive(Debug)]
struct Raster<C>(Vec<Vec<C>>);
impl<C> Raster<C> {
fn apply<I, F: Fn(&C) -> I>(&self, function: F) -> Raster<I> {
Raster(
self.0
.iter()
.map(|row| row.iter().map(|pixel| function(pixel)).collect())
.collect(),
)
}
fn convert<I: for<'a> From<&'a C>>(&self) -> Raster<I> {
self.apply(|pixel| pixel.into())
}
}
/// https://en.wikipedia.org/wiki/SRGB#Transfer_function_(%22gamma%22)
impl From<&SRgb> for Rgb {
fn from(value: &SRgb) -> Self {
fn transfer(channel: f64) -> f64 {
if channel <= 0.04045 {
channel / 12.92
} else {
((channel + 0.055) / 1.055).powf(2.4)
}
}
Self {
r: transfer(value.r),
g: transfer(value.g),
b: transfer(value.b),
}
}
}
/// https://en.wikipedia.org/wiki/SRGB#Transfer_function_(%22gamma%22)
impl From<&Rgb> for SRgb {
fn from(value: &Rgb) -> Self {
fn inverse_transfer(channel: f64) -> f64 {
if channel < 0. {
-inverse_transfer(-channel)
} else if channel <= 0.0031308 {
12.92 * channel
} else {
1.055 * channel.powf(1. / 2.4) - 0.055
}
}
Self {
r: inverse_transfer(value.r),
g: inverse_transfer(value.g),
b: inverse_transfer(value.b),
}
}
}
impl From<&Rgb> for Xyz {
fn from(value: &Rgb) -> Self {
Self {
x: 0.4124 * value.r + 0.3576 * value.g + 0.1805 * value.b,
y: 0.2126 * value.r + 0.7152 * value.g + 0.0722 * value.b,
z: 0.0193 * value.r + 0.1192 * value.g + 0.9505 * value.b,
}
}
}
impl From<&Xyz> for Lms {
fn from(value: &Xyz) -> Self {
Self {
l: 0.4002 * value.x + 0.7076 * value.y + -0.0808 * value.z,
m: -0.2263 * value.x + 1.1653 * value.y + 0.0457 * value.z,
s: 0.9182 * value.z,
}
}
}
impl From<&Lms> for Rgb {
fn from(value: &Lms) -> Self {
Self {
r: 5.47250449 * value.l + -4.64219699 * value.m + 0.16956890 * value.s,
g: -1.12470958 * value.l + 2.29262899 * value.m + -0.16786338 * value.s,
b: 0.02992745 * value.l + -0.19325300 * value.m + 1.16341292 * value.s,
}
}
}
fn chromatic_adaption(pixel: &Lms, source: &Lms, target: &Lms) -> Lms {
let d: f64 = F * (1. - (1. / 3.6) * f64::exp((-L_A - 42.) / 92.));
Lms {
l: ((target.l / source.l) * d + 1. - d) * pixel.l,
m: ((target.m / source.m) * d + 1. - d) * pixel.m,
s: ((target.s / source.s) * d + 1. - d) * pixel.s,
}
}
/// Perform chromatic adaption on an LMS image
/// Takes source and target illuminants in LMS form as inputs
/// https://en.wikipedia.org/wiki/CIECAM02#CAT02
fn chromatic_adaption_raster(lms: &Raster<Lms>, source: &Lms, target: &Lms) -> Raster<Lms> {
lms.apply(|pixel| chromatic_adaption(pixel, source, target))
}
/// Compute LMS coordinates coordinate of the D illuminant of the given temperature (in K)
/// Color temperature is rectified (e.g. 6500K -> 6503.51K).
/// Standard value of 1 for Y is used
fn standard_illuminant_d(temperature: f64) -> Result<Lms, &'static str> {
// Adjust temperature (you know, Planck's constant sometime changes)
let t: f64 = temperature * (C_2 / 1.4380);
// Compute xy (CIE 1931) coordinates of the illuminant
let x_d: f64;
if temperature < 1667. {
return Err("No D illuminant below 1667K.");
} else if temperature <= 4000. {
// /!\ Planckian locus approximation
x_d = -0.2661239 * (1e9 / t.powf(3.)) - 0.2343589 * (1e6 / t.powf(2.))
+ 0.8776956 * (1e3 / t)
+ 0.179910
} else if temperature <= 7000. {
x_d = 0.244063 + (0.09911 * (1e3 / t)) + (2.9678 * (1e6 / t.powf(2.)))
- (4.6070 * (1e9 / t.powf(3.)));
} else if temperature <= 25000. {
x_d = 0.237040 + (0.24748 * (1e3 / t)) + (1.9018 * (1e6 / t.powf(2.)))
- (2.0064 * (1e9 / t.powf(3.)));
} else {
return Err("No D illuminant above 25000K");
}
let y_d: f64;
if temperature <= 2222. {
y_d = -1.1063814 * x_d.powf(3.) - 1.34811020 * x_d.powf(2.) + 2.18555832 * x_d - 0.20219683
} else if temperature <= 4000. {
y_d = -0.9549476 * x_d.powf(3.) - 1.37418593 * x_d.powf(2.) + 2.09137015 * x_d - 0.16748867;
} else {
y_d = (-3.000 * (x_d.powf(2.))) + (2.870 * x_d) - 0.275;
}
// Assuming Y = 1, convert xy (to xyY) to XYZ
let xyz: Xyz = Xyz {
x: (1. / y_d) * x_d,
y: 1.,
z: (1. / y_d) * (1. - x_d - y_d),
};
// Convert to LMS
let lms: Lms = Lms::from(&xyz);
Ok(lms)
}
fn main() -> Result<(), Box<dyn Error>> {
let mut args: Args = std::env::args();
args.next();
let input_path: &str = &args
.next()
.ok_or("First argument must be the path to the input file")?;
let output_path: &str = &args
.next()
.ok_or("Second argument must be the path to the output file")?;
// Target color temperature
let target_illuminant: Lms = standard_illuminant_d(
args.next()
.map(|temperature| temperature.parse::<f64>().unwrap_or(4000.))
.unwrap_or(4000.),
)?;
// sRGB encoding illuminant
let source_illuminant: Lms = standard_illuminant_d(
args.next()
.map(|temperature| temperature.parse::<f64>().unwrap_or(6500.))
.unwrap_or(6500.),
)?;
let path: &Path = Path::new(input_path);
let file: File = File::open(&path)?;
let ppm: PPM = PPM::read(file)?;
let s_rgb_raster: Raster<SRgb> = Raster::from(&ppm);
// Multiple functions version
// Caution: memory intensive!
/*
let rgb_raster: Raster<Rgb> = s_rgb_raster.convert::<Rgb>();
let xyz_raster: Raster<Xyz> = rgb_raster.convert::<Xyz>();
let lms_raster: Raster<Lms> = xyz_raster.convert::<Lms>();
let lms_raster_adapt: Raster<Lms> =
chromatic_adaption_raster(&lms_raster, &source_illuminant, &target_illuminant);
let rgb_raster_adapt: Raster<Rgb> = lms_raster_adapt.convert::<Rgb>();
let s_rgb_raster_adapt: Raster<SRgb> = rgb_raster_adapt.convert::<SRgb>();
*/
// Single function version
let s_rgb_raster_adapt: Raster<SRgb> = s_rgb_raster.apply(|pixel| {
SRgb::from(&Rgb::from(&chromatic_adaption(
&Lms::from(&Xyz::from(&Rgb::from(pixel))),
&source_illuminant,
&target_illuminant,
)))
});
let output: PPM = PPM::from((&s_rgb_raster_adapt, ppm.maxval));
output.write(File::create(Path::new(output_path))?)?;
Ok(())
}
is this #0000ff
yes it is!
post a comment