Skip to content

Releases: leafo/imagesize

v1.1.0

Choose a tag to compare

@leafo leafo released this 24 Oct 01:17
v1.1.0

New formats

  • WebP: lossy (VP8), lossless (VP8L), and extended (VP8X) files, including alpha and animation. Animated files report the canvas size. Needs at most 30 bytes.
  • BMP: Windows and OS/2 bitmaps, including top-down files with a negative height. Returns bit_depth.
  • MP4: new imagesize.mp4 module with detect_mp4(read, file_size) and detect_mp4_from_bytes(bytes). It takes a read callback since moov is often at the end of the file, so only the box headers and moov need to be fetched (typically 3 to 5 reads). Returns the first video track's width, height, and rotation, the duration, the brand, and every track's handler and codec. See the README for details.

Changes

  • GIF size now matches browsers. The logical screen size is used, falling back to the first frame's size when it is larger or the file is GIF87a. Previously the first frame's size was always used, so animated GIFs whose first frame is smaller than the canvas will now report a larger size.
  • JPEGs with an EXIF orientation tag return an orientation field (1 to 8). width and height are still the stored dimensions, so for orientations 5 to 8 the displayed image has them swapped.
  • Dimensions are integers on Lua 5.3+. Previously they were floats, eg. 50.0.

Fixes

  • A JPEG segment with a length of 0 or 1 raised a Lua error instead of returning nil.
  • A JPEG with a few hundred APP1 segments raised a backtrack stack overflow error.
  • JPEGs using SOF3, SOF5 to SOF7, SOF9 to SOF11, or SOF13 to SOF15 (lossless, arithmetic, and hierarchical) failed to detect.
  • JPEGs with 0xFF fill bytes before a marker failed to detect.
  • GIFs with application extensions other than NETSCAPE (eg. XMP or ICC profiles), plain text extensions, empty comments, or unknown extensions failed to detect.

Other

  • Tested on Lua 5.1 through 5.5, LuaJIT, and OpenResty's LuaJIT.

Full Changelog: v1.0.0...v1.1.0

Initial release

Choose a tag to compare

@leafo leafo released this 12 Apr 17:48

https://luarocks.org/modules/leafo/imagesize

Initial release, see README for useage.