code wiki / _hdl_build / nx_galx_thumb_oneshot.nx
nx_galx_thumb_oneshot.nx
buildroot/runtime/_hdl_build/nx_galx_thumb_oneshot.nx
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
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
structs
| none |
consts
| 34 | const K_MAGIC_8192: i64 = 8192 |
functions
| 36 | func 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 } |
| 37 | func 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 |
| 40 | func 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 } |
| 42 | func main(argc: i64, argv: *i64) -> i64 |