首页 > 解决方案 > 当从我的数据库中导入图像并在图库中输出时,它们会变得模糊吗?

问题描述

图像模糊 原始图像

我在 php 中有一个简单的图片上传功能。它获取图像并将其作为 blob 上传到数据库。当我将图像调用到画廊时,它变得模糊。有没有办法解决这个问题,我听说有人使用 GD 等。我的代码在下面,用于上传和调用。

画廊.php

<div data-u="slides" style="cursor:default;position:relative;top:0px;left:0px;width:1300px;height:500px;overflow:hidden;">
              <?php 
              $result = mysqli_query($connection, "SELECT * FROM tbl_images"); 

              while($row = mysqli_fetch_array($result))
  {
            ?>
            <div>
                <?php echo'<img width="100%" height:"100%" class="img-fluid" src="data:image/jpg;base64,' . base64_encode($row['name']) . '"  />' ?>

            </div>
  <?php } ?>

上传文件.php

            <?php   
 if(isset($_POST["insert"]))  
 {  
      $file = addslashes(file_get_contents($_FILES["image"]["tmp_name"]));  
      $query = "INSERT INTO tbl_images(name) VALUES ('$file')";  
      if(mysqli_query($connection, $query))  
      {  
           echo '<script>alert("Image Inserted into Database")</script>';  
      }  
 } 

 ?>  

标签: htmlcssimage

解决方案


尝试将image-rendering: pixelatedCSS 样式添加到您的img元素。


推荐阅读