code wiki / _hdl_build / nx_galx_thumb_oneshot.nx

nx_galx_thumb_oneshot.nx

buildroot/runtime/_hdl_build/nx_galx_thumb_oneshot.nx

7722 B122 linesdepth 8pulls 22 transitivereach 0 importersview sourcekind tooltopic galx
docsdependenciesstructsconstsfunctions

about

nx_galx_thumb_oneshot.nx -- SOVEREIGN gallery THUMBNAIL generator (kills full-res-into-160px-cells waste). WARNING: THIS IS *NOT* nx_galx_thumb.nx. Separate organ, and it IS the binary deployed at the gallery root as /volume1/ai/galx/nx_galx_thumb.elf (sha 0b760f5b, 100856 B). The FILENAME collides and this HEADER used to collide as well, which has now caused the same misdiagnosis at least twice -- see the nx_galx_thumb.elf.prev-batch-mistake fossil sitting beside it. The two organs are NOT interchangeable: this (oneshot) : argv = <src> <out> [maxdim=384] POSITIONAL ; emits BASELINE COLOR JPEG q72 nx_galx_thumb : argv = one|batch SUBCOMMAND ; emits PNG at a hardcoded TH_MAX=256 MEASURED 2026-08-31, one image: this = 18892 B JPEG at 384 ; nx_galx_thumb one = 113861 B PNG at 256, i.e. 6.03x LARGER at LOWER resolution -- a regression in the exact metric this organ exists to optimise. All three consumers (nx_gallery_serve gs_thumb_run, nx_media_server ms_thumb_run, nx_media_ingest_pipeline mp_run) pass the POSITIONAL form and write <cid>.jpg served as image/jpeg. Installing nx_galx_thumb here BREAKS thumbnails: it exits 2 unknown mode, the rename never happens, and the grid silently degrades to full-res. Verified by running both binaries, 2026-08-31. The gallery serves /img/<cid> = the FULL-RESOLUTION image into the grid (nx_gallery_serve.nx:2 "no thumbnails") -> a grid page downloads ~60 multi-MB images = the dominant "performance is awful". World-class galleries NEVER serve full-res into a grid (research: thumbnail pyramids / responsive variants). This composes PROVEN sovereign organs (DRY #15, zero 3rd-party): nx_png_decode -> nx_img_scale_bilinear (the nc=3 path nx_img_convert already ships) -> nx_png_write_rgb. One-shot CLI; the gallery generates-on-first-view + caches, so each thumbnail is computed once. usage: nx_galx_thumb <src.png> <out.png> [maxdim=384] (aspect-preserving, never upscales) expect_exit: 0 ok ; nonzero = unreadable/undecodable/unsupported (caller falls back to full-res) license_tier: ORIGINAL

dependencies 9 imports · 0 importers

nx_syscalls.nx nx_png_decoder.nx nx_img_scale.nx nx_png_write.nx nx_jpeg_color_write.nx nx_quant_table.nx nx_jpeg_huff_enc.nx nx_zigzag.nx nx_dct8.nx nx_galx_thumb_oneshot.nx

imports: nx_syscalls.nxnx_png_decoder.nxnx_img_scale.nxnx_png_write.nxnx_jpeg_color_write.nxnx_quant_table.nxnx_jpeg_huff_enc.nxnx_zigzag.nxnx_dct8.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gt_puts sys_write gt_atoi sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close nx_png_decode sys_mmap ↻ _png_check_signature _png_read_u32_be nx_crc32 nx_crc32_update nx_crc32_init nx_crc32_table_at _png_n_channels _png_bytes_per_pixel _png_n_channels ↻ _png_a7_expected _png_a7_col0 _png_a7_coli

structs

none

consts

34const K_MAGIC_8192: i64 = 8192

functions

36func gt_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(2, s, n); return 0 }
called by 1: main calls 1: sys_write
37func gt_atoi(s: *u8) -> i64 { var v: i64 = 0; var i: i64 = 0; while s[i] != (0 as u8) { let c: i64 = s[i] as i64; if c < 48 { return v } if c > 57 { return v } v = v * 10 + (c - 48); i = i + 1 } return v }
called by 1: main
40func gt_num(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; var neg9: i64=0; if m<0{m=0-m;neg9=1}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} if neg9==1{t[k]=45 as u8;k=k+1}; var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1}; sys_write(2,b,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
42func main(argc: i64, argv: *i64) -> i64