2

I am looking for a way to load only a part of a jpg. I tried XMLHttpRequest but I could not figure it out.

    request.open("GET", "js.jpg", true);
    request.responseType = "blob";

This gets me an image and I can use it to display it. For example the image is 100kb big, I only want 50kb. Is this possible. I know that the image is cracked but I want to try something. Thank you

edit:

My goal is to load for example 50kb instead of the whole 100kb to save traffic I guess ;)

Kronos
  • 141
  • 1
  • 11
  • Have your server deliver 50 kb instead of 100kb. You can't control how much you receive on the client side. Also, saving traffic by breaking things isn't exactly the smartest move you can make. – Mjh May 28 '15 at 11:00
  • rather then thinking at javascript you put logic at server side to provide 2 version of each images (hq and low quality)!!! you can decrease quality at serverside – kishan May 28 '15 at 11:00

1 Answers1

-3

I did this by putting the image inside a div, and the div height = image height / 2. of course, in my app the div height is a portion of the available screen height so that in different pc browser or mobile browser or Webview in native Android or iPhone, the display are similar.

Kenneth Li
  • 1,632
  • 1
  • 14
  • 19