Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some questions about Bitmap #70

Open
Means88 opened this issue Nov 8, 2019 · 2 comments
Open

Some questions about Bitmap #70

Means88 opened this issue Nov 8, 2019 · 2 comments

Comments

@Means88
Copy link
Contributor

Means88 commented Nov 8, 2019

STORAGE_DIR is removed after build, however it is shared between instances. If I'm processing a and b at the same time, bitmaps added to b will be lost after a.build().

fs.removeSync(STORAGE_DIR);

We may use os.tmpdir() if the directory is used temporarily. For developers who want to control the storage (like me 😄), they can specify the STORAGE_DIR environment and clean up manually.


const fileHash = md5File.sync(args.filePath);

The filename of a bitmap looks like a sha1 hash because it has 160bit length (40 * 0~f). But it's different from the sha1 of original image or the image inside sketch file, so I don't know how it is generated exactly (maybe it doesn't matter).

I wonder whether images from different sketch file can get conflicted (different bitmap with the same filename)? Or we can just assume that different image has a different filename?


BitmapLayer is exported from 'bitmap/index.d.ts', which is not the same as 'bitmap/index.js'

export interface BitmapLayer {

It should be the declaration for 'index.js' like declare class Bitmap { ... }

I checked some of my sketch files and didn't find any layers with _class: bitmapLayer (and not found in sketch-hq/sketch-file-format). Is there anything I've missed, or just some mistakes?

@dbanksdesign
Copy link
Member

The filename of a bitmap looks like a sha1 hash because it has 160bit length (40 * 0~f). But it's different from the sha1 of original image or the image inside sketch file, so I don't know how it is generated exactly (maybe it doesn't matter).

I spoke someone at Sketch about this. They do use sha1, but that Sketch might process the data from the file before hashing it which is why I never got a consistent hash value. They said the filename probably doesn't matter though.

You are right that 'BitmapLayer' should be 'Bitmap'. I think maybe earlier versions of Sketch called it 'bitmapLayer' or maybe we just got it wrong. I just tested it now and it should be 'bitmap' and here is the schema: https://github.com/sketch-hq/sketch-file-format/blob/master/schema/layers/bitmap.schema.yaml

@L2jLiga
Copy link
Contributor

L2jLiga commented Nov 20, 2019

We may use os.tmpdir() if the directory is used temporarily. For developers who want to control the storage (like me 😄), they can specify the STORAGE_DIR environment and clean up manually.

Very nice suggestion :)
If we have not STORAGE_DIR environment variable specified -> use temporary directory, like it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants