Home > Bug reports > BUG sur filtres_images > image_recadre_mini

Bug report #355 - BUG sur filtres_images > image_recadre_mini

Created on Wednesday 13 May 2020 by Patrice4

Assigned to:
This bug has been assigned to nobody.

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 :

<span class="co1">// Ligne 446 :</span>
<span class="kw1">while</span> <span class="br0">&#40;</span><span class="re0">$yy</span> <span class="sy0">&lt;=</span> <span class="re0">$height</span> <span class="sy0">/</span> <span class="nu0">2</span> and <span class="re0">$max_y</span> <span class="sy0">&lt;=</span> <span class="re0">$min_y</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$yy</span> <span class="sy0">&lt;</span> <span class="re0">$min_y</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                <span class="kw1">for</span> <span class="br0">&#40;</span><span class="re0">$xx</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$xx</span> <span class="sy0">&lt;</span> <span class="re0">$width</span><span class="sy0">;</span> <span class="re0">$xx</span><span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                        <span class="re0">$color_index</span> <span class="sy0">=</span> <a href="http://www.php.net/imagecolorat"><span class="kw3">imagecolorat</span></a><span class="br0">&#40;</span><span class="re0">$im</span><span class="sy0">,</span> <span class="re0">$xx</span><span class="sy0">,</span> <span class="re0">$yy</span><span class="br0">&#41;</span><span class="sy0">;</span>
                        <span class="re0">$color_tran</span> <span class="sy0">=</span> <a href="http://www.php.net/imagecolorsforindex"><span class="kw3">imagecolorsforindex</span></a><span class="br0">&#40;</span><span class="re0">$im</span><span class="sy0">,</span> <span class="re0">$color_index</span><span class="br0">&#41;</span><span class="sy0">;</span>
                        <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$color_tran</span><span class="br0">&#91;</span><span class="st_h">'alpha'</span><span class="br0">&#93;</span> <span class="sy0">!==</span> <span class="nu0">127</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                                <span class="re0">$min_y</span> <span class="sy0">=</span> <a href="http://www.php.net/min"><span class="kw3">min</span></a><span class="br0">&#40;</span><span class="re0">$yy</span><span class="sy0">,</span> <span class="re0">$min_y</span><span class="br0">&#41;</span><span class="sy0">;</span>
                                <span class="re0">$max_y</span> <span class="sy0">=</span> <a href="http://www.php.net/max"><span class="kw3">max</span></a><span class="br0">&#40;</span><span class="re0">$height</span> <span class="sy0">-</span> <span class="nu0">1</span> <span class="sy0">-</span> <span class="re0">$yy</span><span class="sy0">,</span> <span class="re0">$max_y</span><span class="br0">&#41;</span><span class="sy0">;</span>
                                <span class="kw1">break</span><span class="sy0">;</span>
                        <span class="br0">&#125;</span>
                <span class="br0">&#125;</span>
        <span class="br0">&#125;</span>
        <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$height</span> <span class="sy0">-</span> <span class="nu0">1</span> <span class="sy0">-</span> <span class="re0">$yy</span> <span class="sy0">&gt;</span> <span class="re0">$max_y</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                <span class="kw1">for</span> <span class="br0">&#40;</span><span class="re0">$xx</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$xx</span> <span class="sy0">&lt;</span> <span class="re0">$width</span><span class="sy0">;</span> <span class="re0">$xx</span><span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                        <span class="re0">$color_index</span> <span class="sy0">=</span> <a href="http://www.php.net/imagecolorat"><span class="kw3">imagecolorat</span></a><span class="br0">&#40;</span><span class="re0">$im</span><span class="sy0">,</span> <span class="re0">$xx</span><span class="sy0">,</span> <span class="re0">$height</span> <span class="sy0">-</span> <span class="nu0">1</span> <span class="sy0">-</span> <span class="re0">$yy</span><span class="br0">&#41;</span><span class="sy0">;</span>
                        <span class="re0">$color_tran</span> <span class="sy0">=</span> <a href="http://www.php.net/imagecolorsforindex"><span class="kw3">imagecolorsforindex</span></a><span class="br0">&#40;</span><span class="re0">$im</span><span class="sy0">,</span> <span class="re0">$color_index</span><span class="br0">&#41;</span><span class="sy0">;</span>
                        <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$color_tran</span><span class="br0">&#91;</span><span class="st_h">'alpha'</span><span class="br0">&#93;</span> <span class="sy0">!==</span> <span class="nu0">127</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                                <span class="re0">$min_y</span> <span class="sy0">=</span> <a href="http://www.php.net/min"><span class="kw3">min</span></a><span class="br0">&#40;</span><span class="re0">$yy</span><span class="sy0">,</span> <span class="re0">$min_y</span><span class="br0">&#41;</span><span class="sy0">;</span>
                                <span class="re0">$max_y</span> <span class="sy0">=</span> <a href="http://www.php.net/max"><span class="kw3">max</span></a><span class="br0">&#40;</span><span class="re0">$height</span> <span class="sy0">-</span> <span class="nu0">1</span> <span class="sy0">-</span> <span class="re0">$yy</span><span class="sy0">,</span> <span class="re0">$max_y</span><span class="br0">&#41;</span><span class="sy0">;</span>
                                <span class="kw1">break</span><span class="sy0">;</span>
                        <span class="br0">&#125;</span>
                <span class="br0">&#125;</span>
        <span class="br0">&#125;</span>
        <span class="re0">$yy</span><span class="sy0">++;</span>
<span class="br0">&#125;</span>

Code corrigé :

<span class="co1">// Ligne 446 :</span>
<span class="kw1">while</span> <span class="br0">&#40;</span><span class="re0">$yy</span> <span class="sy0">&lt;=</span> <span class="re0">$height</span> <span class="sy0">/</span> <span class="nu0">2</span> and <span class="re0">$max_y</span> <span class="sy0">&lt;=</span> <span class="re0">$min_y</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
        <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$yy</span> <span class="sy0">&lt;</span> <span class="re0">$min_y</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                <span class="kw1">for</span> <span class="br0">&#40;</span><span class="re0">$xx</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$xx</span> <span class="sy0">&lt;</span> <span class="re0">$width</span><span class="sy0">;</span> <span class="re0">$xx</span><span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                        <span class="re0">$color_index</span> <span class="sy0">=</span> <a href="http://www.php.net/imagecolorat"><span class="kw3">imagecolorat</span></a><span class="br0">&#40;</span><span class="re0">$im</span><span class="sy0">,</span> <span class="re0">$xx</span><span class="sy0">,</span> <span class="re0">$yy</span><span class="br0">&#41;</span><span class="sy0">;</span>
                        <span class="re0">$color_tran</span> <span class="sy0">=</span> <a href="http://www.php.net/imagecolorsforindex"><span class="kw3">imagecolorsforindex</span></a><span class="br0">&#40;</span><span class="re0">$im</span><span class="sy0">,</span> <span class="re0">$color_index</span><span class="br0">&#41;</span><span class="sy0">;</span>
                        <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$color_tran</span><span class="br0">&#91;</span><span class="st_h">'alpha'</span><span class="br0">&#93;</span> <span class="sy0">!==</span> <span class="nu0">127</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                                <span class="re0">$min_y</span> <span class="sy0">=</span> <a href="http://www.php.net/min"><span class="kw3">min</span></a><span class="br0">&#40;</span><span class="re0">$yy</span><span class="sy0">,</span> <span class="re0">$min_y</span><span class="br0">&#41;</span><span class="sy0">;</span>
                                <span class="coMULTI">/* $max_y = max($height - 1 - $yy, $max_y); */</span>
                                <span class="re0">$max_y</span> <span class="sy0">=</span> <a href="http://www.php.net/max"><span class="kw3">max</span></a><span class="br0">&#40;</span><span class="re0">$yy</span><span class="sy0">,</span> <span class="re0">$max_y</span><span class="br0">&#41;</span><span class="sy0">;</span>
                                <span class="kw1">break</span><span class="sy0">;</span>
                        <span class="br0">&#125;</span>
                <span class="br0">&#125;</span>
        <span class="br0">&#125;</span>
        <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$height</span> <span class="sy0">-</span> <span class="nu0">1</span> <span class="sy0">-</span> <span class="re0">$yy</span> <span class="sy0">&gt;</span> <span class="re0">$max_y</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                <span class="kw1">for</span> <span class="br0">&#40;</span><span class="re0">$xx</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$xx</span> <span class="sy0">&lt;</span> <span class="re0">$width</span><span class="sy0">;</span> <span class="re0">$xx</span><span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                        <span class="re0">$color_index</span> <span class="sy0">=</span> <a href="http://www.php.net/imagecolorat"><span class="kw3">imagecolorat</span></a><span class="br0">&#40;</span><span class="re0">$im</span><span class="sy0">,</span> <span class="re0">$xx</span><span class="sy0">,</span> <span class="re0">$height</span> <span class="sy0">-</span> <span class="nu0">1</span> <span class="sy0">-</span> <span class="re0">$yy</span><span class="br0">&#41;</span><span class="sy0">;</span>
                        <span class="re0">$color_tran</span> <span class="sy0">=</span> <a href="http://www.php.net/imagecolorsforindex"><span class="kw3">imagecolorsforindex</span></a><span class="br0">&#40;</span><span class="re0">$im</span><span class="sy0">,</span> <span class="re0">$color_index</span><span class="br0">&#41;</span><span class="sy0">;</span>
                        <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$color_tran</span><span class="br0">&#91;</span><span class="st_h">'alpha'</span><span class="br0">&#93;</span> <span class="sy0">!==</span> <span class="nu0">127</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
                                <span class="coMULTI">/* $min_y = min($yy, $min_y); */</span>
                                <span class="re0">$min_y</span> <span class="sy0">=</span> <a href="http://www.php.net/min"><span class="kw3">min</span></a><span class="br0">&#40;</span><span class="re0">$height</span> <span class="sy0">-</span> <span class="nu0">1</span> <span class="sy0">-</span> <span class="re0">$yy</span><span class="sy0">,</span> <span class="re0">$min_y</span><span class="br0">&#41;</span><span class="sy0">;</span>
                                <span class="re0">$max_y</span> <span class="sy0">=</span> <a href="http://www.php.net/max"><span class="kw3">max</span></a><span class="br0">&#40;</span><span class="re0">$height</span> <span class="sy0">-</span> <span class="nu0">1</span> <span class="sy0">-</span> <span class="re0">$yy</span><span class="sy0">,</span> <span class="re0">$max_y</span><span class="br0">&#41;</span><span class="sy0">;</span>
                                <span class="kw1">break</span><span class="sy0">;</span>
                        <span class="br0">&#125;</span>
                <span class="br0">&#125;</span>
        <span class="br0">&#125;</span>
        <span class="re0">$yy</span><span class="sy0">++;</span>
<span class="br0">&#125;</span>

1 comment

Bug report or comment only available for registered users.

Log in.