How to take a full resolution picture with camera in nativescript? - nativescript

I'd like to take a full resolution picture with nativescript camera module ... but i can't !
I know how to do that with cordova but not in nativescript :-( and all examples are with small res like 300x300.
const options = {
width: 300,
height: 300,
keepAspectRatio: false,
saveToGallery: true
};
I'm looking for something like "0x0" or no width and height options but if i try to put 4096x3072 (my camera resolution) the result is "out of memory".
Thanks

Try to use nativescript media file picker https://www.npmjs.com/package/nativescript-mediafilepicker Or nativescript camera plus https://market.nativescript.org/plugins/#nstudio%2Fnativescript-camera-plus for full screen camera.

Related

Crop image with react-native

Hello World,
I trying to crop an image like explain on the React-native Doc
<Image source={{uri: this.props.image, crop: {left: 50, top: 50, width: 100, height: 100}}} style={{height: 100, width: 100}}/>
But it's doesn't work the image is not cropped.
Any idea?
From the docs:
On the infrastructure side, the reason is that it allows us to attach metadata to this object. For example if you are using require('./my-icon.png'), then we add information about its actual location and size (don't rely on this fact, it might change in the future!). This is also future proofing, for example we may want to support sprites at some point, instead of outputting {uri: ...}, we can output {uri: ..., crop: {left: 10, top: 50, width: 20, height: 40}} and transparently support spriting on all the existing call sites.
React Native Image is not currently supporting image cropping, at least not the way you pointed, however you still have other options that will do the same job.
ImageEditor:
React Native Component, again from the docs:
Crop the image specified by the URI param. If URI points to a remote
image, it will be downloaded automatically. If the image cannot be
loaded/downloaded, the failure callback will be called.
Cropping doesn't require linking.
Image Crop Picker another package that offers cropping, but in a different way: Picking. Requires linking, but thankfully it also supports RN versions > 0.40.
I haven't used any of them, but if I were you, I would first try Image Editor, since you don't need any additional installation except importing.
you can use package for cropping the image. first package for uploading image and second for cropping the image.
react-native-image-picker
react-native-image-crop-picker
for uploading image you can use first package function like this
const pickImage = () => {
launchImageLibrary({quality: 0.5}, response => {
if (!response.didCancel) {
setUri(response.assets[0]);
setCropImg('');
}
});
};
for cropping the image you can use second package function like this
const Crop_img = () => {
ImagePicker.openCropper({
path: uri.uri,
width: dimensions.width - 30,
height: dimensions.height / 3.5,
maxFiles: 1,
showCropFrame: false,
}).then(image => {
console.log(image.path);
setCropImg(image.path);
});
};

Circular image edges are jagged in Alloy appcelerator

I am trying to make an circular image view in Alloy appcelerator formerly Titanium like this
XML
<ImageView id="profile_photo" />
TSS
"#profile_photo_view_holder":{
width: 80,
height: 80,
borderRadius: 40,
borderWidth:2,
borderColor:"black"
}
The image view is rendering properly but jaggy in its edges looks like an anti aliasing problem.
I use image factory module to scale down also but no luck.
resizedImage = ImageFactory.imageAsResized(blob, {
width : 80,
height : 80,
quality : 0.9
});
$.profile_photo.image = resizedImage;
on Android you will need to make use of a module to achieve it.
This module is quite new and looks great:
https://github.com/m1ga/com.miga.roundview
I'm using this one in my project:
https://github.com/snowciety/sc.roundedavatar
Hope it helps

Erase part of Konvajs image

I'm trying to upload a local image to a konvajs stage and then erase parts of the image that are not needed. My upload works well and the draw/erase work but I'm unable to erase the uploaded image. I can only erase the draw line over the image.
var stage = new Konva.Stage({
container: 'container',
width: width,
height: height
});
I have created a jsfiddle: https://jsfiddle.net/tommy6s/L3f27mch/
I read two stackoverflow posts similar to mine that featured a round eraser tip but I still could not figure out how to get mine to work.
Any help is appreciated. Thank you.
For this demo I was using separate <canvas> element for drawing canvas.
You can draw your image directly into canvas via context:
img.onload = function() {
context.drawImage(img, 0,0, width/2, height / 2)
layer.draw();
};
Demo

PhoneGap camera getPictue - get full image quality

I am making an app where an photo is taken and sent to the server, but the files that get sent are of low quality. It seems that when I take a photo using iOS native camera app it come out as a very sharp picture, but when using PhoneGap it reduces the quality massively.
I have set the image quality to 100 etc:
function capturePhoto() {
// Take picture using device camera and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoURISuccess, onPhotoURIFail, {
quality: 100,
destinationType: Camera.DestinationType.FILE_URI,
//destinationType: Camera.DestinationType.DATA_URL,
//destinationType: Camera.DestinationType.NATIVE_URI,
sourceType : Camera.PictureSourceType.CAMERA,
correctOrientation: true,
saveToPhotoAlbum: true,
encodingType: Camera.EncodingType.PNG
});
}
But still seems to give a real blurry image.
Has anyone else had this problem? I have also tried using the DATA_URL to get the base64 encoded image, but this makes the app go so slow that I couldn't get to a stage to send to the server.
Is there a way to use the original LOSSLESS file?
Thanks
function capturePhoto() {
navigator.camera.getPicture(onPhotoURISuccess, onPhotoURIFail, {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
sourceType : Camera.PictureSourceType.CAMERA,
correctOrientation: false,
encodingType: Camera.EncodingType.PNG,
targetWidth: 1500,
targetHeight: 1500
});
}
Im not sure why mine wouldn't work before, but it may have been because I was trying it on my iPad? I can't quite remember if I had the same problem with my iPhone also at that time.
Also the way the imageURI is retrieved may have made a difference, not sure about that either, but here is my code to get the image URI:
function onPhotoURISuccess(imageURI){
$('#imagePreview img.smallImage').attr("src", imageURI);
}
And then just get the URI from the image when you want to send. It prety much exactly like all the examples but for some reason didn't work before.
Make sure you have your plugins using the latest version too. That's about it!

How to draw a line on image using appcelerator titanium mobile

I'm want to make an application for Galaxy Tab, that allows me to draw pictures... Something similar to MS Paint (don't ask my why :)) so the first steps are:
win = Ti.UI.createWindow({
backgroundColor: 'black',
exitOnClose: true
});
image = Ti.UI.createImageView({
width: 200,
height: 200
});
image.addEventListener('touchmove', function(e){
//And here I need somehow to draw a pixel on image at e.x, e.y coordinates
// How can i do it?
});
So, how should i draw a pixel?
sorry I have not read you full Question.
try This, this is a Titanium Appcelerator Module and this is absoultely free
It have also a easy example. You can use easy.
Again Really Sorry..

Resources