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