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
Related
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.
I can't get resizeMode='contain' to work for images loaded remotely, wondering if there's something I've done wrong.
Render Method:
return (
<View style={styles.internal_button_avatar_container}>
<Image
style={styles.internal_button_avatar_image}
source={{ uri: this.state.imageURL }}
loadingIndicatorSource={require('../assets/icons/PageLink-Loading.png')}
resizeMode={'contain'}
/>
</View>
);
Styles (relevant section):
internal_button_avatar_container: {
marginRight: 10,
width: 40,
height: 40,
},
internal_button_avatar_image: {
width: 40,
height: 40,
},
I've tried resizeMode='contain' and resizeMode='center' but the image always is cropped around the outside of it's frame. Screenshot showing cropped icon.. I've also tried with undefined height and width on the image.
The cropping only appears to happen if the source image is not the same aspect ratio as the frame, a square source will result in perfectly scaled image.
I tried to reproduce your situation, but I haven't problems with that in this snack:
https://snack.expo.io/#gersonmontenegro/resizemode
The original size of the image is bigger than the container, even it has a different aspect radio, and it has loaded according to the internal_button_avatar_image.
Is ok for you?
Turns out I was getting the image from an endpoint in an API that auto-cropped the original image - should've checked the source image before everything else!
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);
});
};
I'm trying to display an image with a URI location instead of a static image and it's not working. I'm getting the red screen with the message:
You are trying to render the global Image variable as a React element.
You probably forgot to require Image.
I simply took the default project (react-native init awesomeProject) and added this inside the View after the two Text elements:
<Image
style = {styles.base}
source={{uri: 'http://facebook.github.io/react/img/logo_og.png'}}
/>
and I enhanced the styles with an additional property:
base: {
height: 400,
width: 400
},
I can't figure out why this wouldn't work as this is the simple example in the React Native docs. Any advice?
Make sure to actually require the Image component:
var React = require("react-native");
var Image = React.Image;
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..