sketch-hq/SketchAPI

How to setOverrideValue with local image path?

miaopeng opened this issue · 0 comments

[Help Needed]
I wondering how to setOverrideValue with a local image file? This is my code but not working:

const nsImage = NSImage.alloc().initByReferencingFile(imagePath);
console.log('\t nsImage', nsImage);

const image = Image.fromNative(nsImage);

symbolInstance.setOverrideValue(override, image);

the console log:

override type Image
override property imageResizeBehavior
override editable true

	 nsImage <NSImage 0x600001da7840 Size={800, 600} RepProvider=<NSImageURLReferencingRepProvider:0x600002a1fd60 url:file:///....pathofmyfile/data/01.png reps:(
    "NSBitmapImageRep 0x60000048d490 Size={800, 600} ColorSpace=(not yet loaded) BPS=8 BPP=(not yet loaded) Pixels=800x600 Alpha=YES Planar=NO Format=(not yet loaded) CurrentBacking=nil (faulting) CGImageSource=0x600002c590c0"

Sketch Version: 100