2

I am trying to resize image in Angular+Nativescript app after retrieving from URL but receving following error:-

ERROR Error: Uncaught (in promise): TypeError: imageSource.resize is not a function. (In 'imageSource.resize(100)', 'imageSource.resize' is undefined)

Below is the code:-

image.html

<Image (loaded)="onImageLoaded($event)" class="img-home-event" stretch="aspectFill">
 </Image> 

image.module.ts

onImageLoaded(args)
{        
        let image = <Image>args.object;
        
        ImageSource.fromUrl("https://homepages.cae.wisc.edu/~ece533/images/airplane.png")
        .then((imageSource) =>{
            image.imageSource = imageSource.resize(100);
            image.height = 150;
            image.width = 150;
        });        
}

Please help me here. I require resize functionality to be implemented in my project. If this is not possible then please provide some alternative.

simple user
  • 349
  • 3
  • 22
  • 44
  • Does this problem still occur when the image is fetched from the **exact same** `Origin` that the page is on? – JamesTheAwesomeDude Mar 25 '21 at 18:48
  • Yes. My requirement is to fetch image from Amazon S3 bucket or from internet. This problem is still coming. The origin of page will not be same as origin of image in my case. – simple user Mar 25 '21 at 19:02
  • try to resize the image instead of the imageSource. – Tiago Machado Mar 29 '21 at 13:58
  • Can you please tell me of way to resize image on fly? I want to say if there is any function in nativescript which can resize image before showing in pp. – simple user Mar 29 '21 at 18:33
  • Check to see if there's any CORS error message in your console. Sometimes an asset on a site is accessible directly from the browser, but not using AJAX. Also What `console.log(typeof imageSource)`outputs ? – Nelson Teixeira Apr 01 '21 at 17:53

1 Answers1

0

This error got resolved when I upgrade my Project to NS7+. I learnt later that resize() functionality worked in NativeScript after version 6.5.9

simple user
  • 349
  • 3
  • 22
  • 44