Cropper: How to get the zoom amount?

Created on 14 Apr 2015  路  3Comments  路  Source: fengyuanchen/cropper

The function getData() can get everything about the image besides its current zoom level.
Is it possible to get this?

Most helpful comment

You should use relative ratio on the zoom method:

var image = $('img').cropper('getImageData');

$('img').cropper('zoom', (image.naturalWidth - image.width) / image.width);

All 3 comments

Use getImageData method:

var image = $('img').cropper('getImageData');

image.zoomLevel = image.width / image.naturalWidth;

@fengyuanchen - I'm getting the zoom level (using your above method( and then using the same number to set the zoom using zoom(). Unfortunately this is not setting the zoom level as it originally was?

You should use relative ratio on the zoom method:

var image = $('img').cropper('getImageData');

$('img').cropper('zoom', (image.naturalWidth - image.width) / image.width);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

rajjanorkar picture rajjanorkar  路  4Comments

SimonBriche picture SimonBriche  路  7Comments

jloguercio picture jloguercio  路  6Comments

ThameDBA picture ThameDBA  路  4Comments

Mafial picture Mafial  路  8Comments