How to resize then crop an image with canvas

后端 未结 3 1978
一向
一向 2020-11-28 07:17

I already know how to

-> resize an image:

var image = document.getElementById(\'myImage\'),
    canvas = document.createElement(\'canvas\'),
    ctx          


        
3条回答
  •  情书的邮戳
    2020-11-28 07:32

    I took this tutorial as an example http://tympanus.net/codrops/2014/10/30/resizing-cropping-images-canvas/ and did the same thing in vanilla js. It probably needs some refacturing but it is working (at least on my windows labtop in chrome)

    One html file:

    
    
     
    
    
    Document
    
     
      
     
    Image

提交回复
热议问题