Now with Partition Management

    jpeg-buffer-orientation
    TypeScript icon, indicating that this package has built-in type declarations

    4.1.1 • Public • Published

    jpeg-buffer-orientation

    gzip size

    Travis Codacy Badge Coveralls github

    devDependencies Issues Issues GitHub last commit GitHub Release Date

    styled with prettier MIT license

    Get orientation of JPEG file.

    Install

    yarn add --dev jpeg-buffer-orientation

    Usage

    in browser

    <script type="module">
      import getOrientation from 'https://unpkg.com/jpeg-buffer-orientation?module'
    
      const response = await fetch('./foo.jpg')
      const buffer = await response.arrayBuffer()
      const orientation = getOrientation(buffer)
    
      console.log('orientation', orientation)
    </script>

    demo

    in browser (legacy)

    <script src="https://unpkg.com/jpeg-buffer-orientation"></script>
    <script>
      const buffer = myJpegFile.arrayBuffer()
      console.log(getOrientation(buffer))
    </script>

    in node (not recommended)

    import fs from 'node:fs/promises'
    import getOrientation from 'jpeg-buffer-orientation'
    
    const myJpegFile = new URL('./foo.jpg', import.meta.url)
    const {buffer} = await fs.readFile(myJpegFile)
    const orientation = getOrientation(buffer)
    console.log('orientation', orientation)

    API

    getJpegOrientation(buffer)

    • buffer

      type: ArrayBuffer

    • @returns

      type: Number|undefined

    FYI

    this package is design for use in browser, not optimized for node.

    1. accept Buffer instead of ArrayBuffer should be easier to use.
    2. instead of reading the whole image, just reading head maybe better.

    Keywords

    none

    Install

    npm i jpeg-buffer-orientation

    DownloadsWeekly Downloads

    44

    Version

    4.1.1

    License

    MIT

    Unpacked Size

    57.1 kB

    Total Files

    14

    Last publish

    Collaborators

    • fisker