Get Image Width & Height? - nativescript

How can I get the width and height of an image in NativeScript?
I've tried referencing like:
<Image src="~/assets/images/logo.jpg" ref="img1"/>
And getting the width like:
this.$refs.img1.getMeasuredWidth
But no luck.

Related

VideoPlayer height fit content / No black bars

I wan't my VideoPlayer to have the height of the Video itself, so that there are no black bars. This way I can't set height to a constant value because on different devices with different width, the video has black bars. When I do this:
<VideoPlayer #video
src="https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"
autoplay="true"
fill="false"
muted="true">
</VideoPlayer>
It looks like this:
I know the video aspect ratio is 16/9.
I tried something like this: [height]="video.clientWidth / (16/9)" but it's not working.
What can i do?

d3.tree scrollbar instead of panning

I have a tree width d3.js. when tree overflows svg, it is hidden and I can view hidden parts by panning on tree. is there any way to add scrollbar for view hidden parts instead of panning?
for example in this sample http://bl.ocks.org/robschmuecker/7880033 I want to add scroll bar to this tree. this sample is not what I want: https://bl.ocks.org/CrandellWS/ca7e6626c9e6b1413963
because in this example when we collapse nodes, scrollbar size not change.
You can get the svg bounding box using svg.getBBox(), where svg is your svg node, e.g.
let svg = document.getElementsByTagName("svg")[0];
let box = svg.getBBox()
and then use box.x, .y, .width and .height to calculate the correct viewBox attribute value, width and height.

Xamarin image fills the page

Hello I'm developing a Xamarin.Forms application.
I have this code and the image fits to page on simulator.
How can I display the image in its original size?
var image = new Image { Aspect = Aspect.AspectFit};
image.Source = "image2.png";
Content = image;
To set the dimensions of an image you can't use the Width and Height properties. Because the Width and Height properties are read-only (as the error said).
Try to use the WidthRequest and HeightRequest properties to set your desired dimension.
Infos from Xamarin-Developer-Page:
WidthRequest does not immediately change the Bounds of a
VisualElement, however setting the WidthRequest will change the result
of calls to GetSizeRequest, which will in turn modify the final size
the element receives during a layout cycle.

How to maintain and apply aspect ratio of images in extjs4

I am working in extjs4. I am trying to display image by using following component=
xtype : 'image',
height : 600,
width : 800,
src :me.imageSrc
Where,me.imageSrc is having image path. But sometimes image is shown as blurred or expanded if image's height and width is too large. So how to calculate aspect ratio and apply it in extjs4 in order to show images properly.
In order to get the size of the loaded image you need to listen the "load" event on the image element, in the listener callback you have access to the with and height.
Here's the code that makes the magic:
var img = imageCmp.imgEl
img.on('load',function(){
Ext.Msg.alert('IMG Size',img.getWidth()+'x'+img.getHeight());
});
Here's a working example:
http://jsfiddle.net/crysfel/utUA2/
Make sure you remove the hardcoded width and height ;)

Resizing images in Etalage Jquery Zoom plugin using Javascript

I am working on a webpage that lists the details of a product .
The product details include an image that can be zoomed using the Etalage Jquery Zoom plugin.
I am able to change the image that is displayed in the Etalage Jquery plugin depending on certain attributes of the product.
I am dynamically changing the images by executing the statement
$('#etalage').etalage({
show_descriptions: false,
small_thumbs: 0
}).show();
The problem is that the source image looses its assigned height and width.
I would like to know how to assign a height and width to the source image using JavaScript
after changing the image in the Etalage plugin.
Regards
Mathew
Resolved this issue by observing the values that were being assigned to the
following parameters when the size of the source image was correct.
Assigning those values while calling the show() method solved my problem
$('#etalage').etalage({
show_descriptions: false,
small_thumbs: 0,
source_image_width: 900, // The source/zoomed image width (not the frame around it) (value in pixels)
source_image_height: 1200,
thumb_image_width:480, // The large thumbnail width (excluding borders / padding) (value in pixels)
thumb_image_height: 480,
autoplay:false,
zoom_area_width: 340, // Width of the zoomed image frame (including borders, padding) (value in pixels)
zoom_area_height:495, // Height of the zoomed image frame (including borders, padding) (value in pixels / 'justify' = height of large thumb + small thumbs)
zoom_area_distance: 20,
}).show();

Resources