I have a KineticJS 5.1.0 stage on an iPhone 5. Due to the screen size of the iPhone my stage is bounded by 320px x 320px. The image I capture is 1280px x 1280px. I want to be able to process this image on the stage without loosing quality due to shrinking.
Here is the original image (Big version: https://dl.dropboxusercontent.com/u/47067729/originalImage2.jpg):
Here is what happens, when I load the image into the stage:
The image looks very strange it has a lot of strips inside as you can see on the image.
When I apply a filter the image looks like this.
Which is not what it should look like.
I created a JsFiddle (http://jsfiddle.net/confile/qhm7dn09/) which shows this problem
console.clear();
var imageObj = new Image();
var img = null;
var saveBtn = document.getElementById("save");
var resultImage = document.getElementById("resultImage");
var original = document.getElementById("original");
var downloadLink = document.getElementById("DownloadLink");
Kinetic.pixelRatio = 4;
stage = new Kinetic.Stage({
container: 'container',
width: 320,
height: 320
});
layer = new Kinetic.Layer();
img = new Kinetic.Image({
x: 0,
y: 0,
image: new Image()
});
layer.add(img);
stage.add(layer);
imageObj.onload = function() {
var tmpWidth = Math.floor(imageObj.width /2);
var w = Math.min(tmpWidth, 320);
var h = imageObj.height * w / imageObj.width;
img.setImage(this);
img.setWidth(w);
img.setHeight(h);
img.cache(); // 5.1.0
// img.setFilter(Kinetic.Filters.Shinny); // 4.5.2.
img.filters([Kinetic.Filters.Shinny]); // 5.1.0
layer.draw();
};
imageObj.crossOrigin = "anonymous";
var imageUrl = "https://dl.dropboxusercontent.com/u/47067729/originalImage2.jpg";
imageObj.src = imageUrl;
original.src = imageUrl;
saveBtn.onclick = function(evt) {
console.log("save");
var canvas = $(stage.getContent()).find('canvas').get(0);
console.log("canvas: "+canvas);
var dataURL = canvas.toDataURL('image/jpeg', 1.0);
resultImage.src = dataURL;
downloadLink.href = dataURL;
};
How can I edit an image which is much bigger than my screen/stage size without loosing quality?
Edit: The stage/canvas which is present to the user is still some kind of preview. The original image should not be downscaled. After applying effects and exporting the stage I want to have to exported image to be of the same size as the original one without quality reduction. I do not want to resize a 320px x 320px stage back to 1280px x 1280px which would cause a hugh quality loss.