How can I get a trimmed image size with base 64 string

Hi guys,

Now I’m developing some game using cocos creator.

I think this engine so awesome.

But I don’t know how to get my goal.

First, I got a image data from server with base64 format and make up this with sprite with code.
like this.

getTextureFromString(imgString) {
const imgAsset = new ImageAsset(imgString);
const tex = new Texture2D();
tex.image = imgAsset;
return tex;
}
getSpriteFrameFromString(imgString) {
const spriteFrame = new SpriteFrame();
spriteFrame.texture = this.getTextureFromString(imgString);
return spriteFrame;
}

this works very fine but when I use this code I can’t use trim option.

When I use spriteframe located in inspector it shows trimx, trimy right.

But when I use base64 string to make sprite, it shows original size and trimmed size are same.

How can I get a trimmed size with code?

I think I can calculate “ISpriteFrameInitInfo” with code, But I can’t find how to do it.

I need some help

thank you

you need ro reset spriteFrame info.
like this:

The images loaded with base64 are not cut by default.
rect → {x:0,y:0,width: originalSize.width,height: originalSize.heght}

I try this but still I can’t get a trimmed size.

the original size of image is 250x 690 but actual size(trimmed) is 149 x 298

Is there any function can get the actual size?

Do you need this?
cc.find('Canvas/Sprite').getComponent(cc.Sprite).spriteFrame.originalSize