Skip to content

Instantly share code, notes, and snippets.

@benfoxall
Created January 16, 2021 17:14
Show Gist options
  • Select an option

  • Save benfoxall/47a8ce7ed12b14e79dffa1048e2c2fa7 to your computer and use it in GitHub Desktop.

Select an option

Save benfoxall/47a8ce7ed12b14e79dffa1048e2c2fa7 to your computer and use it in GitHub Desktop.

Revisions

  1. benfoxall created this gist Jan 16, 2021.
    11 changes: 11 additions & 0 deletions gifsize.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    await gifsize('https://media.giphy.com/media/3ornjZLITGcFQVRbxK/source.gif')
    // > {width: 500, height: 247}


    async function gifsize (url) {
    const result = await fetch(url, {headers: {Range: 'bytes=6-9'}})

    const [width, height] = new Uint16Array(await result.arrayBuffer())

    return {width, height}
    }