Utilizo Jquery Jcrop para recortar mis imágenes. Ahora estoy implementando un control deslizante para cambiar el tamaño de la imagen. Quiero que el recorte y cambio de tamaño ocurra en la misma página.Cambiar el tamaño de la imagen que utiliza Jcrop
lo hago de esta manera:
$(document).ready(function() {
var img = $('#cropbox')[0]; // Get my img elem
var orgwidth, orgheight;
$("<img/>") // Make in memory copy of image to avoid css issues
.attr("src", $(img).attr("src"))
.load(function() {
orgwidth = this.width; // Note: $(this).width() will not
orgheight = this.height; // work for in memory images.
});
$('#cropbox').Jcrop({
onSelect: updateCoords
});
$("#imageslider").slider({
value: 100,
max: 100,
min: 1,
slide: function(event, ui) {
//$('ul#grid li').css('font-size',ui.value+"px");
resizeImage(orgwidth, orgheight);
}
});
});
Y mi función simple resizeImage:
function resizeImage(orgwidth, orgheight) {
var value = $('#imageslider').slider('option', 'value');
var width = orgwidth * (value/100);
var height = orgheight * (value/100);
$('#cropbox').width(width);
$('#cropbox').height(height);
$('#tester').val("org: "+orgwidth+" now: "+width);
}
El problema es que, tan pronto se enciende el Jcrop no puedo cambiar el tamaño de la imagen. ¿Cómo puedo usar ambas funciones al mismo tiempo?
Usando esto como una base He presentado una solicitud de extracción aquí: https://github.com/tapmodo/Jcrop/pull/69 – homerjam
¡Gracias! Funcionando bien – user706420