imagelib.md 1.8 KB


title: imagelib section: imagelib

order: 110

imagelib.getImageDimension(vpath)

Returns [width, height].

var dim = imagelib.getImageDimension("user:/img.jpg");

imagelib.resizeImage(src, dest, width, height)

imagelib.resizeImage("user:/img.jpg", "user:/img_small.jpg", 800, 600);

imagelib.resizeImageBase64(src, width, height, format)

Returns data URL string.

var b64 = imagelib.resizeImageBase64("user:/img.jpg", 320, 240, "jpeg");

imagelib.cropImage(src, dest, x, y, width, height)

imagelib.cropImage("user:/img.jpg", "user:/crop.jpg", 10, 10, 200, 200);

imagelib.loadThumbString(vpath)

Returns cached thumbnail base64 string.

var thumb = imagelib.loadThumbString("user:/img.jpg");

imagelib.hasExif(vpath)

Reads JPEG, TIFF based RAW and HEIC / HEIF (iPhone) photos.

if (imagelib.hasExif("user:/img.jpg")) echo("has exif");

imagelib.getExif(vpath)

Returns JSON string. JPEG, TIFF based RAW and HEIC / HEIF photos.

var exif = JSON.parse(imagelib.getExif("user:/img.jpg"));

imagelib.renderPreview(src, dest, maxWidth, maxHeight)

Draws a photo upright and scaled down to fit maxWidth x maxHeight, keeping its shape (0 leaves a side free; smaller photos are not enlarged). Reads JPEG, PNG, WebP, GIF, HEIC / HEIF and RAW (its embedded JPEG) and applies the EXIF orientation. dest is a .jpg or .png path (folders are created); pass "" to get a JPEG data URL instead of writing a file. Returns {width, height} (plus dataURL when dest is ""). Pictures over 120 MP are refused.

var p = imagelib.renderPreview("user:/Photo/a.heic", "user:/.appdata/photo/previews/a.jpg", 720, 1440);
var inline = imagelib.renderPreview("user:/Photo/b.jpg", "", 480, 480).dataURL;