How to convert image(static openstreetmap) into base64 string using javascript

I need to convert a static map image.I found the following code:

function toDataURL(url, callback) {
  var xhr = new XMLHttpRequest();
  xhr.onload = function() {
    var reader = new FileReader();
    reader.onloadend = function() {
      callback(reader.result);
    }
    reader.readAsDataURL(xhr.response);
  };
  xhr.open('GET', url);
  xhr.responseType = 'blob';
  xhr.send();
}

toDataURL('https://www.gravatar.com/avatar/d50c83cc0c6523b4d3f6085295c953e0', function(dataUrl) {
  console.log('RESULT:', dataUrl)
})

The problem is that any other image is generated very well, but from this link:

http://staticmap.openstreetmap.de/staticmap.php?center=52.6240,20,3744&zoom=10&size=640×640&maptype=mapnik&format=png

This does not work 🙁

Link to items such as DOM works, but this conversion is not working. Do you have any idea what’s wrong with my link?

Thanks for any replies 🙂


Source: stackoverflow-javascript

How to resize image using php

I want to convert the image in low resolution with GD. I’m working on IBM Server under these speces
Version: PHP 7.0.15-0ubuntu0.16.04.4 (cli) ( NTS )
and I have also comment out the extension from php.ini but can’t enabled the GD on php server.
I Just received this error.

Run Command: sudo apt-get install libgd

Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package libgd

Second Command When I run give this message:

1) packages have unmet dependencies

Cause of this Problem:

PHP Fatal error: Uncaught Error: Call to undefined function imagecreatefromstring()

Note please anyone tell me the step-by-step command to enable this GD Library on my this Linus machine.
thanks alot


Source: stackoverflow-php

How to get name attribute of an image from php when click on it

I want to get the name attribute of an imagen when someone click on it.
Then, with the name, I will access a MySQL database with this name as a searching parameter for the query.
But I am not able to get the name of an image from php.

Can someone help me?

This is the code that I have, I suppose to have a php function in the onclick attr.

<a class="img_a" onclick="" name="xxx">   
    <figure class="img_figure">
        <img class="img_user" src="users/xxx.png" alt="">
    </figure>
</a>

<a class="img_a" onclick="" name="yyy">   
    <figure class="img_figure">
        <img class="img_user" src="users/yyy.png" alt="">
    </figure>
</a>


Source: stackoverflow-php

PHP ajax image upload multiplies

Spent whole night with this script
but cant fix the bug.
it would be better if anyone can help me on this

say if i select an image and click upload it uploads current image file
then if i select another image and click upload it upload 2 new files u=in directory and it increase every time

here is my sourcecode


Source: stackoverflow-php