WebGL perspective transform image cropping issue

by budapestflyer

HTML

<script src="https://evanw.github.io/glfx.js/glfx.js"></script>
<img id="image" crossOrigin="anonymous" src="https://images.unsplash.com/photo-1485207801406-48c5ac7286b2?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&s=9bb1a18da78ab0980d5e7870a236af88" width="500">

JavaScript

// try to create a WebGL canvas (will fail if WebGL isn't supported)
try {
	var canvas = fx.canvas();
} catch (e) {
	alert(e);
	return;
}

// convert the image to a texture
var image = document.getElementById('image');
var texture = canvas.texture(image);

// apply the perspective filter
canvas.draw(texture).perspective( [0,0,774,0,0,1094,774,1094], [0,389,537,0,732,1034,1269,557] ).update();

image.src = canvas.toDataURL('image/png');

// or even if you replace the image with the canvas
// image.parentNode.insertBefore(canvas, image);
// image.parentNode.removeChild(image);