View Thumbnails

2

I have a page in PHP that contains WHILE which should show thumbnail image according to the images I have in the same directory.

    <?php
while($fetch = mysql_fetch_assoc($select)){
 ?>
        <tr class="row-content1">
           <td class="check"> <label><input type="checkbox" value=""></label></td>
           <td> <?php echo $fetch['nickname']; ?>  </td>
           <td><?php echo $fetch['sala']; ?></td>
           <td><?php "<img  src='thumb.php?img=image/".$fetch['imagem'];"'>"?></td>
           <td><input type="image" src="LOG_29710.png" data-toggle="modal" data-target="#myModal<?php echo $fetch['id']; ?>"></td>
           <td><?php echo $fetch['quote']; ?></td>
           <td><?php echo $fetch['aprovado']; ?></td>

      </a>
</td>
     ?>

The file thumb.php is who does all the work to generate the thumbnail. However, the images do not appear, it does not generate error but in the field of the image / thumbnail, it is left blank. If I leave the image out of the thumb.php, the original image appears. I have another project that works fine, I used exactly the same template, but it does not work.

Follow the thumb.pbp

function mimeType($file)
{
    $mimetype = false;

    if (class_exists('finfo')) {//PHP5.4+
        $finfo     = finfo_open(FILEINFO_MIME_TYPE);
        $mimetype  = finfo_file($finfo, $file);
        finfo_close($finfo);
    } else if (function_exists('mime_content_type')) {//php5.3 ou inferiror
        $mimetype = mime_content_type($file);
    }

    return $mimetype;
}

$filename = $_GET['img'];
$percent = 0.10;

//Lê o formato do conteudo da imagem
$mime = mimeType($filename);

if (strpos($mime, 'image/') !== 0) {
    die('Este arquivo não é uma imagem');
}

//Remove o prefixo image/
$mime = substr($mime, 6);

//Remove 'x' de x-jpeg, talvez ocorram em alguns servidores antigos
$mime = str_replace('x-', '', $mime);

switch ($mime) {
    case 'jpeg':
        $image = imagecreatefromjpeg($filename);
    break;
    case 'png':
        $image = imagecreatefrompng($filename);
    break;
    case 'gif':
        $image = imagecreatefromgif($filename);
    break;
    default:
        die('Formato não aceito');
}

// Cabeçalho que ira definir a saida da pagina
header('Content-type: image/jpeg');

// pegando as dimensoes reais da imagem, largura e altura
list($width, $height) = getimagesize($filename);

//setando a largura da miniatura
$new_width = 120;
//setando a altura da miniatura
$new_height = 100;

//gerando a a miniatura da imagem
$image_p = imagecreatetruecolor($new_width, $new_height);

imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

//o 3º argumento é a qualidade da imagem de 0 a 100
imagejpeg($image_p, null, 50);
imagedestroy($image_p);
    
asked by anonymous 13.12.2017 / 21:43

0 answers