Code Duplication    Length = 21-21 lines in 2 locations

ecrire/inc/filtres_images_lib_mini.php 2 locations

@@ 1326-1346 (lines=21) @@
1323
 * @param int $maxHeight Hauteur maximum souhaitée
1324
 * @return array Liste [ largeur, hauteur, ratio de réduction ]
1325
 **/
1326
function _image_ratio($srcWidth, $srcHeight, $maxWidth, $maxHeight) {
1327
	$ratioWidth = $srcWidth / $maxWidth;
1328
	$ratioHeight = $srcHeight / $maxHeight;
1329
1330
	if ($ratioWidth <= 1 and $ratioHeight <= 1) {
1331
		$destWidth = $srcWidth;
1332
		$destHeight = $srcHeight;
1333
	} elseif ($ratioWidth < $ratioHeight) {
1334
		$destWidth = $srcWidth / $ratioHeight;
1335
		$destHeight = $maxHeight;
1336
	} else {
1337
		$destWidth = $maxWidth;
1338
		$destHeight = $srcHeight / $ratioWidth;
1339
	}
1340
1341
	return array(
1342
		ceil($destWidth),
1343
		ceil($destHeight),
1344
		max($ratioWidth, $ratioHeight)
1345
	);
1346
}
1347
1348
/**
1349
 * Réduire des dimensions en respectant un ratio sur la plus petite dimension
@@ 1364-1384 (lines=21) @@
1361
 * @param int $maxHeight Hauteur maximum souhaitée
1362
 * @return array Liste [ largeur, hauteur, ratio de réduction ]
1363
 **/
1364
function ratio_passe_partout($srcWidth, $srcHeight, $maxWidth, $maxHeight) {
1365
	$ratioWidth = $srcWidth / $maxWidth;
1366
	$ratioHeight = $srcHeight / $maxHeight;
1367
1368
	if ($ratioWidth <= 1 and $ratioHeight <= 1) {
1369
		$destWidth = $srcWidth;
1370
		$destHeight = $srcHeight;
1371
	} elseif ($ratioWidth > $ratioHeight) {
1372
		$destWidth = $srcWidth / $ratioHeight;
1373
		$destHeight = $maxHeight;
1374
	} else {
1375
		$destWidth = $maxWidth;
1376
		$destHeight = $srcHeight / $ratioWidth;
1377
	}
1378
1379
	return array(
1380
		ceil($destWidth),
1381
		ceil($destHeight),
1382
		min($ratioWidth, $ratioHeight)
1383
	);
1384
}
1385
1386
1387
/**