jayesh chaudhary
jayesh chaudhary

Reputation: 1

JQuery After resize image canvas resize only image not a canvas

JQuery After resize image canvas resize only image not a canvas

function resizeImage(width, height){
    var image = document.getElementById('resizeImage'),
    canvas = document.createElement('canvas'),
    ctx = canvas.getContext('2d');
    ctx.drawImage(image,cropLeft, cropTop, cropWidth, cropHeight,10,10,width,height);

    return canvas;
  };

above function resize image but show extra canvas part in return canvas;

How i can get fixed height width resize image using simple jquery html?

Upvotes: 0

Views: 110

Answers (1)

Manoj
Manoj

Reputation: 5071

Try this

function resizeImage(width, height){
    var image = document.getElementById('resizeImage'),
    canvas = document.createElement('canvas'),
    ctx = canvas.getContext('2d');
    ctx.canvas.height = height;//pass height
    ctx.canvas.width = width;//pass width
    ctx.drawImage(image,cropLeft, cropTop, cropWidth, cropHeight,10,10,width,height);
    return canvas;
  };

Upvotes: 1

Related Questions