<分区>
不确定这是不是该问的地方,但我有一张我网站的图片,我在 powerpoint 上删除了它的背景,但是当我上传它时,它周围是白色背景。即使我将背景颜色设置为其他颜色,它也会有我选择的颜色以及它周围的白色。不知道如何摆脱白色,所以希望得到任何指导。
img {
max-width: 50%;
}
<img src="https://jg-ross.000webhostapp.com/pageUploads/logo.png" style="background-color:red; padding:20px;">
我希望没有任何背景,当我在 powerpoint 上加载图像时没有白色,但是一旦我将它上传到我的网站,白色就在那里。
在存储它的图像文件夹中,图像周围还有一个白框,这是什么原因造成的,我可以摆脱它吗?
我是这样上传的,图片存储在sql表中:
<?php
try {
$stmt = $db->query('SELECT image_title, image FROM images WHERE id= 2 ');
while($row = $stmt->fetch()){
echo "<img src='pageUploads/".$row['image']."'height='50px'";
}
}catch(PDOException $e) {
echo $e->getMessage();
}
?>
<?php
require_once('../includes/config.php');
$target_dir = "../pageUploads/";
$target_file = $target_dir . basename($_FILES["image"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
//collect form data
extract($_POST);
$check = getimagesize($_FILES["image"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
// Check if file already exists
if (file_exists($target_file)) {
echo "Sorry, file already exists.";
$uploadOk = 0;
}
// Check file size
if ($_FILES["image"]["size"] > 2000000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["image"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
$upload = basename( $_FILES["image"]["name"]);
try {
//insert into database
$stmt = $db->prepare('INSERT INTO images (image_title,image) VALUES (:image_title, :image)') ;
$stmt->execute(array(
':image_title' => $image_title,
':image' => $upload
));
//redirect to index page
header('Location: images.php?action=added');
exit;
} catch(PDOException $e) {
echo $e->getMessage();
}
?>