nanocontent
nanocontent copied to clipboard
Add height and width to image file data
Maybe this could be hidden in some opts for the general public that don't require variable crop ratio layout calculation on server render. ;)
Super solid stuff. Had thought about this and held off implementing as I’d like to retain feature parity between Node’s fs and the Dat WebArchive API exposed in Beaker Browser. Perhaps checking for the necessary methods to run sizeOf and executing it conditionally is the right call. @jongacnik @s3ththompson
I was imagining this working fine if fs and WebArchive readFile(Sync) both returned a buffer type and beaker had similar buffer API's, but WebArchive gives me an ArrayBuffer.
If reading all the images into a buffer is unnecessary load on beaker – which seems likely – what is the best conditional to put next to parsedFile.type === 'image' to make this feature Node exclusive? (!!fs.statSync maybe)
I might continue to dig a little further into using the ArrayBuffer from the WebArchive API to extract the information needed to do these calculations, just for kicks.
I ran into this issue before with different tradeoffs between server-side (Node) and browser-side (Beaker/web). I think it might be nice to have a standard convention for adding small bits of functionality/metadata where it makes sense on the Node side. I like the idea of checking whether fs is defined.