iPhone + preview big image BUG #124

Open
CavalcanteLeo opened this Issue Oct 22, 2013 · 1 comment

Comments

Projects
None yet
2 participants

I've tried to code an web-app that has to take a picture on the device(iphone or android) and at the same time crop it.

My iPhone takes 8mb photos, and I used canvas to resize it, by then its ok,

But when i try to preview the crop, it shows me a weird image, flattened, but just on mobile, it works fine on iPads, PC and MACS.

I've tried on iPhone 4S iOS7

this is how it looks like on my iPhone:
2013-10-22 15 32 41

this is my code:

        function crop(){
            fotoMomento.Jcrop({
                aspectRatio: 1,
                boxWidth:    tamanhoDiv,
                boxHeight:   tamanhoDiv,
                bgOpacity:   0.2,
                trueSize: [larguraImg, alturaImg],
                onSelect: previewFoto,
                onChange: previewFoto
            })
        };

        function previewFoto(posicaoFoto){
            console.log(
                posicaoFoto.x  + " , " + 
                posicaoFoto.y  + " , " + 
                posicaoFoto.x2 + " , " + 
                posicaoFoto.y2 + " , " + 
                posicaoFoto.w  + " , " + 
                posicaoFoto.h
                );
            if(parseInt(posicaoFoto.w) > 0) {
                $(".preview1").show;
                $("#recortar").removeAttr("disabled");
                // preview do crop
                var imageObj = $("#imagemTirada")[0];
                var canvas = $("#preview")[0];
                var context = canvas.getContext("2d");
                context.drawImage(
                    imageObj, 
                    posicaoFoto.x, 
                    posicaoFoto.y, 
                    posicaoFoto.w, 
                    posicaoFoto.h, 
                    0, 
                    0, 
                    canvas.width, 
                    canvas.height
                );
            }
        };//fim da funcao fazer crop

MadsHL commented Apr 5, 2015

Hey,
If it is any help, I solve a familiar issue with this https://github.com/stomita/ios-imagefile-megapixel
Besides that it is a good idea to compress the image before using jcrop doing to performance.

/Mads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment