Anyone knows what the route is in TS, so that it takes an image and transforms it to base64? Is it to share a local image on Facebook?
regards.
This is my function code:
share(){
let filePath: string = "file:///assets/imgs/pesa4.jpg";
let shreface = this.actioSheetController.create({
buttons:[
{
text:"facebook",
icon:"logo-facebook",
handler:()=>{
this.base64.encodeFile(filePath).then((myBase64: string) => {
this.socialSharing.share(this.message, this.subject, myBase64, this.url)
console.log(myBase64);
})
}
}
]
});
shreface.present();
}
enter image description here
Try with assets/imgs/pesa4.jpg remove "file:///"
If you want to convert local storage image to base64 use file and file chooser plugin.
Related
I am a newbie and am attempting to display an image that is from my Github profile vs hardcoding it into the HTML. Currently, I have coded the following and the object is being displayed in my Javascript console.
const APIURL = 'https://api.github.com/users/'
getUser('JetimLee')
async function getUser(username) {
try {
const {
data
} = await axios(APIURL + username)
console.log(data)
} catch (err) {
console.log(err)
}
}
My question is - how do I get the image from the profile to be displayed? Thank you so much in advance!
You have an avatar_url field, set it's value as source of an image tag in your html.
Example:
const data = await axios('link');
const imgTag = document.getElementById('git-user-id');
imgTag.setAttribute('src', data.avatar_url);
I have URI LIKE below
content://media/external/images/media/5275
but I want convert it to Like format below:
/storage/emulated/0/DCIM/Camera/IMG_00124.jpg
Anyone who can help me!
Sreng Bona
Thanks!
var path = await FlutterAbsolutePath.getAbsolutePath("content://media/external/images/media/5275");
Add this flutter_absolute_path: ^1.0.6 to your file: pubspec.yaml
It will be working as Well.
Bona SR.
I had to search a lot, but I found a very useful solution to save the image in the cell phone's photo gallery and get the absolute path to use it the way you want.
For this example I used a result obtained from saving an image in the photo gallery, however it could also work to read other files, obviously making the changes that you see necessary, I hope it will help you
uri_to_file
image_gallery_saver
import 'dart:io';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:uri_to_file/uri_to_file.dart';
Future<File> saveImage(File image, String identifier) async {
try {
var result = await
ImageGallerySaver.saveImage(image.readAsBytesSync(),
quality: 60, name: identifier +
"-${DateTime.now().toIso8601String()}");
print(result);
File file = await toFile(Uri.parse(result['filePath']));
print(file);
return file;
} catch (e) {
print(e);
return new File('assets/img/default-img.jpg');
}
}
// example
saveImage(File("path/image.jpg"),"img-test");
I'm trying to create a thumbnail from from video on a remove server using the video editor plugin, but just cant get it to work.
The thumbnail doesnt get created.
Below is my code:
private createThumbnail(remoteFileUrl: string) {
this.thumbnailOptions = {
atTime: 60,
height: 1024,
width: 1024,
quality: 100,
fileUrl: remoteFileUrl, // looks something like this : http://example.com/filename.mp4
outputFileName: remoteFileUrl.substring(videoFile.lastIndexOf('/') + 1)
};
this.videoEditor.createThumbnail(this.thumbnailOptions).then(
thumbnail => { this.thumbnail = thumbnail; },
error => { this.thumbnail = '' }
);
}
When i run this code i get the following error
"java.io.FileNotFoundException: file:/http://example.com slash file name -> http://example.com slash file name
Thats because the plugin does only support local video sources and you are trying to load one via the http protocol. Looking at the sourecode of the plugin you can find the following snippet in the createThumbnail() method:
String fileUri = options.getString("fileUri");
if (!fileUri.startsWith("file:/")) {
fileUri = "file:/" + fileUri;
}
}
So if you pass a URI starting with http like in your example it will add file:/ before it - of course - resulting in a FileNotFoundException.
You can try to fork the plugin and modify it according to your needs.
I am new to Perl/Mason.
My url is https://www.myurl.com/myPar/2016image which will return a png image.
In this url, myPar is the parameter (equals to $orderViewHelper->{orderId}).
I have created an orderViewHelper which will hold myImage object so I can access it in other classes. Is there a way that I can use $Std->url() to get the image and put it into myImage?
$orderViewHelper->{myImage} = $Std->url(
'https://www.myurl.com/$orderViewHelper->{orderId}/2016image',
{ absolute =>1 }
);
I think this will work:
$orderViewHelper->{myImage} = $Std->url("https://www.myurl.com/$orderViewHelper->{orderId}/2016image", { absolute =>1 });
I am trying to access an image that i download from remote server. My code to download the file is as below :
var targetPath = cordova.file.documentsDirectory + propp+".png";
var trustHosts = true;
$cordovaFileTransfer.download(url, targetPath, options, trustHosts)
.then(function(result) {
console.log("Local file transfer done");
r = angular.toJson(result.nativeURL);
}, function(err) {
// Error
console.log("error");
});
Then I stored tatgetPath in my local sqlite database. In another page I get this from sqlite and try to display with img tag. But it display like broken Image on Emulator as well as on actual device.
My file url is :
file:///var/mobile/Containers/Data/Application/F7B3169B-D8E3-4F62-AD0B-37CFA381F1CC/Documents/home_bg_image.png
I want to display this image as a background image bit I don't understand how to do this.
After downloading the image you have to paste it in platform/android/assets/www/img-- folder to display the image as
var filedirPath = $ionicPlatform.is('android') ? '/android_asset/www/img/' : 'img';
if not find the path of the image and access the file to display for reference please check this link File path
Having any queries reply ..