سؤال

i try this for long time how can add the image to canvas in html or php only i got the image path i need to load the image to canvas in html or php,i don't need to add the image through jquery or javascript

in html i try this.

<canvas id="myCanvas" width="500" height="500" style="border:1px solid #000000;">
<img src="" alt="Resized Image" height="200px"     
width="200px"></canvas>
هل كانت مفيدة؟

المحلول

There are a few ways to accomplish this.

First, there is a slightly hackish way to do it by setting the background image in css like this:

<canvas id="myCanvas" width="500" height="500" style="border:1px solid #000000;background-image:url('path/to/your/image.ext')">
</canvas>

This will work fine if you just want to display the image, however, I'm assuming that you want to actually manipulate it. In that case, check out this answer.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top