Code Duplication    Length = 21-21 lines in 2 locations

ecrire/inc/filtres_images_lib_mini.php 2 locations

@@ 1236-1256 (lines=21) @@
1233
 * @param int $maxHeight Hauteur maximum souhaitée
1234
 * @return array Liste [ largeur, hauteur, ratio de réduction ]
1235
 **/
1236
function _image_ratio($srcWidth, $srcHeight, $maxWidth, $maxHeight) {
1237
	$ratioWidth = $srcWidth / $maxWidth;
1238
	$ratioHeight = $srcHeight / $maxHeight;
1239
1240
	if ($ratioWidth <= 1 and $ratioHeight <= 1) {
1241
		$destWidth = $srcWidth;
1242
		$destHeight = $srcHeight;
1243
	} elseif ($ratioWidth < $ratioHeight) {
1244
		$destWidth = $srcWidth / $ratioHeight;
1245
		$destHeight = $maxHeight;
1246
	} else {
1247
		$destWidth = $maxWidth;
1248
		$destHeight = $srcHeight / $ratioWidth;
1249
	}
1250
1251
	return array(
1252
		ceil($destWidth),
1253
		ceil($destHeight),
1254
		max($ratioWidth, $ratioHeight)
1255
	);
1256
}
1257
1258
/**
1259
 * Réduire des dimensions en respectant un ratio sur la plus petite dimension
@@ 1274-1294 (lines=21) @@
1271
 * @param int $maxHeight Hauteur maximum souhaitée
1272
 * @return array Liste [ largeur, hauteur, ratio de réduction ]
1273
 **/
1274
function ratio_passe_partout($srcWidth, $srcHeight, $maxWidth, $maxHeight) {
1275
	$ratioWidth = $srcWidth / $maxWidth;
1276
	$ratioHeight = $srcHeight / $maxHeight;
1277
1278
	if ($ratioWidth <= 1 and $ratioHeight <= 1) {
1279
		$destWidth = $srcWidth;
1280
		$destHeight = $srcHeight;
1281
	} elseif ($ratioWidth > $ratioHeight) {
1282
		$destWidth = $srcWidth / $ratioHeight;
1283
		$destHeight = $maxHeight;
1284
	} else {
1285
		$destWidth = $maxWidth;
1286
		$destHeight = $srcHeight / $ratioWidth;
1287
	}
1288
1289
	return array(
1290
		ceil($destWidth),
1291
		ceil($destHeight),
1292
		min($ratioWidth, $ratioHeight)
1293
	);
1294
}
1295
1296
1297
/**