Question

Is there a way to get the naturalWidth on the iPad?

What I'm trying to achieve

Currently I'm developing an quiz app, which has a point-region questiontype. To answer the question, the user has to point a location on an image. That location gets submitted to the server which will return a boolean if the clicked location is within the correct region.

It works perfectly on all browsers and it works on the ipad if the image isn't too big. When the image is too big, it automatically gets resized to fit the screen. Tapping on a certain spot on the image will now give different coordinates then when it would stay in the original size.

I figured out the automatic resizing has to do with the ipad's resource limit. Apperently I can't prevent this, but that isn't much of a problem. I'd just like to know what factor has been used for the resize.

In order to get the factor, I require the original width and the actual width.

Was it helpful?

Solution

I've fixed it by letting the server send the width of the image as HttpHeader (server side language is VB)

Dim objImage As Image = Image.FromFile(strFilePath.ToString())
context.Response.AddHeader("imagewidth", objImage.Width.ToString())
context.Response.ContentType = "text/plain"

Down below you see how I retrieve it client side:

cacheImage.imageWidth = $.ajax( arguments[i] + '&returnsize=true', { async: false } ).getResponseHeader( 'imagewidth' );

arguments[i] is the url to the media loader with a media id as parameter.

returnsize=true

I do not need the width of every media type. Only if I put the returnsize=true after the request, I get the width of the media item.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top