Une option sur image_recadre_mini pour vraiment recadrer au mini (et sans garder le centre de l'image au centre)
{{Procédure }} : function image_recadre_mini($im)
{{Fichier }} : image_transforme.php
{{Plugin_dist}} : filtres_images
{{Bug}} : la fonction ne recadrait pas le bas de l'image.
{{Proposition}} : Après examen du code, il me semble bien qu'une boucle est mal formée. Avec les nouvelles modifications proposées, tout semble fonctionner. A tester tous les cas ceci dit après relecture.
Merci à vous.
{{Code initial :}}
// Ligne 446 : while ($yy <= $height / 2 and $max_y <= $min_y) { if ($yy < $min_y) { for ($xx = 0; $xx < $width; $xx++) {color_index = imagecolorat(
im, $xx, $yy);
color_tran = imagecolorsforindex(
im, $color_index);
if ($color_tran['alpha'] !== 127) {
min_y = min(
yy, $min_y);
max_y = max(
height - 1 - $yy, $max_y);
break;
}
}
}
if ($height - 1 - $yy > $max_y) {
for ($xx = 0; $xx < $width; $xx++) {
color_index = imagecolorat(
im, $xx, $height - 1 - $yy);
color_tran = imagecolorsforindex(
im, $color_index);
if ($color_tran['alpha'] !== 127) {
min_y = min(
yy, $min_y);
max_y = max(
height - 1 - $yy, $max_y);
break;
}
}
}
$yy++;
}
{{Code corrigé :}}
// Ligne 446 : while ($yy <= $height / 2 and $max_y <= $min_y) { if ($yy < $min_y) { for ($xx = 0; $xx < $width; $xx++) {color_index = imagecolorat(
im, $xx, $yy);
color_tran = imagecolorsforindex(
im, $color_index);
if ($color_tran['alpha'] !== 127) {
min_y = min(
yy, $min_y);
/* max_y = max(
height - 1 - $yy, $max_y); */
max_y = max(
yy, $max_y);
break;
}
}
}
if ($height - 1 - $yy > $max_y) {
for ($xx = 0; $xx < $width; $xx++) {
color_index = imagecolorat(
im, $xx, $height - 1 - $yy);
color_tran = imagecolorsforindex(
im, $color_index);
if ($color_tran['alpha'] !== 127) {
/* min_y = min(
yy, $min_y); */
min_y = min(
height - 1 - $yy, $min_y);
max_y = max(
height - 1 - $yy, $max_y);
break;
}
}
}
$yy++;
}