MLX-CL/IO/TIFF
Support TIFF file read and write

Table of Contents

1. About

MLX-CL/IO/TIFF add support for reading and writing mlx-array from and to TIFF file via slyrus/retrospectiff.

NOTE: I'm considering using libTIFF to replace slyrus/retrospectiff.

2. Usage

2.1. Loading

(ql:quickload :mlx-cl/io/tiff)

NOTE: if you load mlx-cl/image, it would automatically load mlx-cl/io/tiff and other image file IO support.

2.2. Reading TIFF file

(mlx-array "xxx.tiff")

2.3. Wrting TIFF file

(destructuring-bind (x y)
    (meshgrid (linspace 0 1 size)
              (linspace 0 1 size))
  (->* (stack x
              y
              (zeros-like x)
              :axis 2)
    (as-dtype (* * 255) :uint8)
    (save * :output "./res/img/write-tiff-example.tif")))

../../res/img/write-tiff-example.tif

NOTE: the original code is from The Book of Shaders:

#ifdef GL_ES
precision mediump float;
#endif

uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;

void main() {
  vec2 st = gl_FragCoord.xy/u_resolution;
  gl_FragColor = vec4(st.x,st.y,0.0,1.0);
}

Author: 凉凉

Created: 2025-11-20 Thu 19:58

Validate