Croppie: Get height and width of cropped image

Created on 19 Oct 2017  路  2Comments  路  Source: Foliotek/Croppie

Hi I want to get X,Y,W,H of the cropped image on cropping.how would I achieve this using croppie plugin.I get cropped points as top left corner points and bottom right corner points but I do not know how to get width, height,X and Y points of the cropped images.

Most helpful comment

You just subtract the left coords from the right coords to get the width and height.

    var info = $('.croppie-image').croppie('get');

    var top_left_x = info.points[0];
    var top_left_y = info.points[1];
    var bottom_right_x = info.points[2];
    var bottom_right_y = info.points[3];

    var cropped_width = bottom_right_x - top_left_x;
    var cropped_height = bottom_right_y - top_left_y;

All 2 comments

You just subtract the left coords from the right coords to get the width and height.

    var info = $('.croppie-image').croppie('get');

    var top_left_x = info.points[0];
    var top_left_y = info.points[1];
    var bottom_right_x = info.points[2];
    var bottom_right_y = info.points[3];

    var cropped_width = bottom_right_x - top_left_x;
    var cropped_height = bottom_right_y - top_left_y;

Thanks @kellishaver

Was this page helpful?
0 / 5 - 0 ratings