image
Image derivatives from an uploaded byte string, pure and with no I/O: decode JPEG, PNG, GIF (first frame), BMP and WebP (lossy, lossless, alpha, the first frame of an animation); turn the frame upright by its EXIF orientation; crop; resize with a stated filter (fill, contain or cover a box); encode PNG, JPEG or WebP with every metadata block dropped. One native pass per derive — the pixels never become a CX value — and a pixel ceiling checked on the header before any decode (CXER7400-7403).
image:info
[$image:info] -> element — The header of an image as [image format= width= height= channels= orientation=]: the container (png, jpeg, gif, bmp, webp), the size it reads upright (an EXIF orientation of 5-8 swaps the stored sides), the stored channel count and the EXIF orientation (1 when none). Nothing is decoded.
[?lib 'cx-stdlib/image']
[$image:info 0x89504e470d0a1a0a0000000d4948445200000008000000060802000000716748ac000000614944415478da0dcbd10000310c44c1a01421080f65511621084559942204e16efea7aa38650a955ddc728a57ae6a9f86b61ab76f93f66baac49111922dae1cf1f48ff119186bf0f80e19bff947383141b1c38d135efeb13e0b6b2d5edf25ebb77c1a373d8126a038b70000000049454e44ae426082::bytes]
[image format=png width=8 height=6 channels=3 orientation=1]
image:derive
[$image:derive] -> bytes — The encoded bytes of a derivative: [derive format=png|jpeg|webp quality=1-100 lossless=true|false max-pixels=N [crop x= y= width= height=] [resize width= height= fit=contain|cover|fill filter=default|box|triangle|b-spline|catmull-rom|mitchell|point]] — the image decoded, turned upright, each operation applied in order, then encoded (PNG by default; JPEG and lossy WebP at quality 85 by default; lossless WebP gives every octet back; alpha is flattened onto white for JPEG). A side resize omits keeps the aspect; filter default is Mitchell when a side shrinks, Catmull-Rom when it grows.
[?lib 'cx-stdlib/image']
[$image:info [$image:derive 0x89504e470d0a1a0a0000000d4948445200000008000000060802000000716748ac000000614944415478da0dcbd10000310c44c1a01421080f65511621084559942204e16efea7aa38650a955ddc728a57ae6a9f86b61ab76f93f66baac49111922dae1cf1f48ff119186bf0f80e19bff947383141b1c38d135efeb13e0b6b2d5edf25ebb77c1a373d8126a038b70000000049454e44ae426082::bytes [derive format=jpeg [resize width=4]]]]
[image format=jpeg width=4 height=3 channels=3 orientation=1]
image:psnr
[$image:psnr] -> decimal — The peak signal-to-noise ratio of one image against another of the same size, in dB over every channel of both decoded upright (100.0 for identical pixels, the cap) — the golden-image measure of the module's corpus.
[?lib 'cx-stdlib/image']
[$image:psnr 0x89504e470d0a1a0a0000000d4948445200000008000000060802000000716748ac000000614944415478da0dcbd10000310c44c1a01421080f65511621084559942204e16efea7aa38650a955ddc728a57ae6a9f86b61ab76f93f66baac49111922dae1cf1f48ff119186bf0f80e19bff947383141b1c38d135efeb13e0b6b2d5edf25ebb77c1a373d8126a038b70000000049454e44ae426082::bytes [$image:derive 0x89504e470d0a1a0a0000000d4948445200000008000000060802000000716748ac000000614944415478da0dcbd10000310c44c1a01421080f65511621084559942204e16efea7aa38650a955ddc728a57ae6a9f86b61ab76f93f66baac49111922dae1cf1f48ff119186bf0f80e19bff947383141b1c38d135efeb13e0b6b2d5edf25ebb77c1a373d8126a038b70000000049454e44ae426082::bytes [derive format=png]]]
100.00