function calcule_scale( compteur , perso ) {
var coef = 1 ;
// alert ( 'codec_video_' + compteur ) ;
if ( $('codec_x264_' + compteur ).checked == true ) { coef = 1.5 ; } ;
var bitrate = parseInt ( $('vbrate_' + compteur ).value ) ;
// alert ( 'vb : ' + bitrate ) ;
var arc = $('aspect_' + compteur ).value ;
if ( perso =='' ) {
var cq = $('cq_' + compteur ).value ;
var y = parseInt ( Math.sqrt ( 1000 * bitrate * coef / 25 / arc / cq ) / 16 ) * 16 ;
var x = parseInt ( y * arc / 16 ) * 16 ;
} else if ( perso == 'x' ) {
var x1 = parseInt ( $('perso_x_' + compteur).value / 16 ) * 16 ;
var x2 = parseInt ( ( $('perso_x_' + compteur).value / 16 ) + 1 ) * 16 ;
if ( ( $('perso_x_' + compteur).value - x1 ) < ( x2 - $('perso_x_' + compteur).value ) ) {
$('perso_x_' + compteur).value = x1 ;
} else { $('perso_x_' + compteur).value = x2 ; }
var yreel = $('perso_x_' + compteur ).value / arc ;
var y1 = parseInt ( yreel / 16 ) * 16 ;
var y2 = parseInt ( ( yreel / 16 ) + 1 ) * 16 ;
if ( ( yreel - y1 ) < ( y2 - yreel ) ) {
var y = y1 ;
} else { var y = y2 ; }
$('perso_y_' + compteur).value = y ;
x = $('perso_x_' + compteur ).value ;
} else if ( perso == 'y' ) {
var y1 = parseInt ( $('perso_y_' + compteur).value / 16 ) * 16 ;
var y2 = parseInt ( ( $('perso_y_' + compteur).value / 16 ) + 1 ) * 16 ;
if ( ( $('perso_y_' + compteur).value - y1 ) < ( y2 - $('perso_y_' + compteur).value ) ) {
$('perso_y_' + compteur).value = y1 ;
} else { $('perso_y_' + compteur).value = y2 ; }
var xreel = $('perso_y_'+ compteur ).value * arc ;
var x1 = parseInt ( xreel / 16 ) * 16 ;
var x2 = parseInt ( ( xreel / 16 ) + 1 ) * 16 ;
if ( ( xreel - x1 ) < ( x2 - xreel ) ) {
var x = x1 ;
} else { var x = x2 ; }
$('perso_x_' + compteur).value = x ;
y = $('perso_y_' + compteur ).value ;
}
$('scale_' + compteur).value = x + ':' + y ;
$('img_' + compteur).style.width = x + 'px' ;
$('img_' + compteur).style.height = y + 'px' ;
}
Tu veux la version php ?
