Skip to content

Large files #154

@Veragin

Description

@Veragin

Hi,

I started using this awsome library. But it has problems with large file (like 100MB and larger)("has problems" means cannot read several image layers). I know there is a lot of articles, saying that, this library is not suitable for large files. But it is possible. Look at https://www.photopea.com/. Its free online photoshop and it can read large .psd files.

I made some research. The problem is with using method toPng():
var des = psd.tree().descendants()[0]; var img = (des.get('image')).toPng();
It returns an image of the layer. It works fine, but allocates a lot of memory, which is not released (for example for 100MB psd file, allocates 300MB for one image (layer)). Its because after using toPng() method, the object psd stores information about layer, like pixelData and so on.

This is 100% fine. But why the pixelData stores information (which are only integers between 0-255) as an classic array. I suggest use Uint8ClampedArray array. I believe that this improvement will reduce the memory size of the pixelData array more than 10 times.

This Uint8ClampedArray array is used also in ImageData object (acquired from canvas HTML element). Here is a figure:
image

I hope my text is comprehensible to developers at least.

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