nativescript-community / ui-image

Advanced and efficient image display plugin which uses Fresco (Android) and SDWebImage (iOS) to implement caching, placeholders, image effects, and much more.
Apache License 2.0
36 stars 9 forks source link

Function 'fromFile' and 'fromFileSync' are not working on android #45

Closed samiul-gtmi closed 1 year ago

samiul-gtmi commented 2 years ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

I used 'fromFile' in NS-v6 to upload image from gallery to app. It was working fine in both android and ios. However after upgrading the NS version from NS-v6 to NS-v8, the 'fromFile' no longer works on android, though it works fine with ios.

Now I came to know that 'fromFile' is deprecated and I should use 'fromFileSync' instead. So, I modified my code from this snippet below

import {ImageSource, fromFile} from 'tns-core-modules/image-source'
 // Android
console.log("Adding from gallery for Android:");

const imageSource:ImageSource =  fromFile(localPath);
const imageHeight:number = imageSource.height;
const imageWidth:number = imageSource.width;
const imageRotationAngle:number = isAndroid ?  imageSource.rotationAngle : null;

to this snippet below:

import { ImageSource } from '@nativescript/core';
// tried below imports also
// let fromFile = require("@nativescript/core/image-source").fromFile;
// import { fromFile } from '@nativescript/core/image-source';
// let fromFileSync = require("@nativescript/core/ImageSource");
// import { fromFileSync } from '@nativescript/core/image-source';

// Android 
  console.log("Adding from gallery for Android:");
  const imageSource:ImageSource = ImageSource.fromFileSync(localPath);
// I also tried- const imageSource:ImageSource = ImageSource.fromFile(localPath);
  const imageHeight:number = imageSource.height;
  const imageWidth:number = imageSource.width;
  const imageRotationAngle:number = isAndroid ?  imageSource.rotationAngle : null;

But nonetheless, it is being problematic. As it is constantly declaring any image file/any uploadable jpg, jpeg or png image files to be invalid format to upload. Kindly let me know if there is any solution to this. Thanks in advance.

farfromrefug commented 2 years ago

@samiul-gtmi how is his related to this plugin?

samiul-gtmi commented 2 years ago

@farfromrefug Thank you for your reply.

Is it not? after I migrated the previous fresco and image to this plugin, the 'fromFile' and 'fromFileSync' stopped working. Also, these two issues are regarding the image URI, which I believe is related to image operations. And the image operations are being taken care of by this plugin.

If you don't think so, then would you care to explain, and suggest me the right action to take?

farfromrefug commented 2 years ago

@@samiul-gtmi fromFile is a function from N this is why i say. And if you migrated your snippet you did not only change this plugin but N too as you were using tns-core-modules. More details /info/debug is needed. I cant help you with just this

samiul-gtmi commented 2 years ago

@farfromrefug Then kindly tell me what do you need, I will present the log before you.

farfromrefug commented 2 years ago

@samiul-gtmi First you need to investigate what really is your issue. And if it is on N side or on this plugin side. Then create a simple repro sample project to reproduce the issue.