Giter Club home page Giter Club logo

leather's People

Contributors

emredalka avatar lehni avatar sidofc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

emredalka ditojs

leather's Issues

Retrieving data about animated png/webp

This project seems awesome.

Does it also work in browser?

It would be awesome, if we could retrieve data such as number of frames in animated png or webp, is something like that planned?

Thank you.

Problem reading dimensions of MP4 files

I tested with these two files, and both cause issues currently:

https://kdrive.infomaniak.com/app/share/505458/af1779c8-11db-4bcf-8e39-55d791d8401d
https://kdrive.infomaniak.com/app/share/505458/3f1cdb78-b7b7-44b4-83a1-a094c022be52

The first one is identified as mp4, but doesn't find the width and height:
{ width: 0, height: 0, size: 19282849, mime: 'video/mp4' }

The second one isn't event found to be an mp4:
{ width: 0, height: 0, size: 0, mime: undefined }

Support reading from buffers instead of files

This library is great and exactly what I am looking for, but sadly it assumes the data is in a file, which isn't the case in my scenario. A big advantage of image-size is that it supports buffers, but sadly doesn't handle videos. Why can't we have both? :)

Wrong extraction of SVG dimensions

If the SVG data contains a <rect> element with width and height attributes, these values will be wrongly used as the width and height of the whole SVG, due to extractWidth() and extractHeight() running the following regular expressions on the full data, instead of just the top-level SVG node:

function extractWidth(data) {
    const matches = data.match(/width=(["'])([^%]+?)\1/i);

    if (matches) return parseDimension(matches[2]);
}

function extractHeight(data) {
    const matches = data.match(/height=(["'])([^%]+?)\1/i);

    if (matches) return parseDimension(matches[2]);
}

Attached an example of an SVG where the wrong dimensions are extracted.

test-1.svg

Use a more specific name instead `attributes` for `import`.

Oh and last feedback for now: I find attributes a bit strange and too generic as an import that one would use in the context of a broader project, because it does not indicate that it's a method reading something or returning something. It sounds like the name of a local variable. I therefore import it like this:

import { attributes as readMediaAttributes } from 'leather'

Something to think about...

Originally posted by @lehni in #9 (comment)

Crash on RangeError: Attempt to access memory outside buffer bounds

Sometimes it crash on trying to determine resolution on buffer (quite hard to reproduce)

RangeError: Attempt to access memory outside buffer bounds
    at new NodeError (node:internal/errors:405:5)
    at boundsError (node:internal/buffer:86:11)
    at Buffer.readUInt8 (node:internal/buffer:254:5)
    at readMediaAttributes (/app/dist/apps/api/node_modules/leather/dist/extractors/jpg.cjs:20:29)
    at readMediaAttributes (/app/dist/apps/api/node_modules/leather/dist/index.cjs:66:40)

it's crashing on this line https://github.com/SidOfc/leather/blob/master/src/extractors/jpg.js#L18
I guess its because sometimes buffer size is smaller then its expected in the code and we need additional check

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.