Accueil > Tickets > BUG sur filtres_images > image_recadre_mini

Ticket #355 - BUG sur filtres_images > image_recadre_mini

Créé le mercredi 13 mai 2020 par Patrice4

Assigné à :
Le ticket n’a été assigné à personne.

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++;
}

1 commentaire

Seules les personnes identifiées peuvent écrire des tickets ou commentaires.

Identifiez vous.