Wordica
Wordica

Reputation: 2597

jQuery Cut Image on Client Side

Are there any chance to cut/croop image on client side ? I search web for plugins but every plugin require server side scripts to save image - and I do not want this. I just want to crop image like:

var my_image = jQuery('.my_class .my_img img');
var my_image_height = jQuery('.my_class .my_img img').height();

if ( my_image_height > 223){
    ... // and what I can do in here. Is there any change for that ? 
        // Best thing will be cut image by X pixels from bottom :)    
}

Some tips ? or this is just impossible ?

Upvotes: 0

Views: 45

Answers (1)

user6748331
user6748331

Reputation:

Yes, you can, but it is not simple. You must load it to canvas, crop it, and then set it as src of particular img element. Or you can simulate crop with CSS. Do not use img element, but div for example, and then set background-image properties in suitable way.

Upvotes: 1

Related Questions