2

I wan to resize an image in SD card sized 3000*4200 px to 250*250 sized profile picture. I tried so many ways using android BitmapFactory, but nothing worked.

Is there any plugin for this?

James Z
  • 12,209
  • 10
  • 24
  • 44

3 Answers3

1

You can use the ImageAsset within framework.

import * as imageAssetModule from "tns-core-modules/image-asset/image-asset";


let asset = new imageAssetModule.ImageAsset(yourPicturePath);
asset.options = {
   width: yourWidth,
   height: yourHeight,
   keepAspectRatio: true // Set to false if you do not want aspect ratio
};

Now you can create an ImageSource from the asset then save it file.

Manoj
  • 21,753
  • 3
  • 20
  • 41
1

ImageSource now supports resize() since @nativescript/core 6.5.9

Basically get your ImageSource and call resize(newSize) on it.

const imgSrc = ImageSource.fromResourceSync('ball');
imgSrc.resize(100);

Here's a video of Alex showing how it works: https://www.youtube.com/watch?v=joXwqCc4JlE

Paaske
  • 4,345
  • 1
  • 21
  • 33
0

Try to this plugin for image resizing and zoom :-

https://market.nativescript.org/plugins/nativescript-image-zoom
FrontEnd-er
  • 661
  • 4
  • 13