Skip to content

Feature Request: Support gzipped PSD in PSD.fromFile() #305

@mk-pmb

Description

@mk-pmb

Hi! I'm trying to write a module that uses yours, and I want to commit test fixture PSDs for it. I could save a lot of bytes by gzip-ing them (82K→11K, 79K→21K), but then I can't easily make a browser demo that way.
Could you maybe add a way for users to plug a decoder function (or even chain thereof) in the right place in PSD.fromFile(), so that my decoder function can check if the file starts with the gzip magic number (0x1F, 0x8B) and then ungzip it using an already loaded gzip library of my choice?
I also tried to find something like .fromUint8Array() or .fromBuffer() in the docs but couldn't find any.

Edit: I just discovered that your node.js code actually uses readFileSync for the .fromFile. That's a DoS hazard, so please warn in the docs that it does! Imagine someone uses that in a server to read a file from a slow drive or even a mounted network share.

At least I see now that I can use new PSD(buffer); could you promote that from hidden hack to official API feature? (Exposing it as .fromBuffer() might still be a more future-proof approach.)
And maybe even give guarantees (via your official tests) that it will also accept Uint8Array in both node.js and browsers?

Update: I've made a stopgap: https://npm.im/psd-pmb

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions