Hello Everybody,
How can i convert an image from .tiff to .jpg using php ?
please , need help !!!
I've already seen many exples on Stackoverflow but there were not helpful.
I'am building a bildgallery using PHP and i created a thumbnails to save the images in this thunmbnails . but i didnt know that many browsers like Chrome or firefox dont support the TIFF files .so i dont hv a choice just to create a PHP function to convert my TIFF files to jpg or png ...
Do you have any Idea ?
Hier is my Code :
<?php
$my_images_arr = scandir("images");
// print_r($my_images_arr);
$img_string = "";
// $imageFileTyp = pathinfo('images', PATHINFO_EXTENSION);
foreach ($my_images_arr as $image_name) {
if(
strlen ($image_name) > 2 && strrpos($image_name,'.db') != true
)
{
$img_string .= '<img src ="images/'.$image_name.'">';
}
elseif
(
strrpos($image_name,'.tif') === true
)
{
$image_name = preg_replace('.tif', '.jpg', $image_name);
}
}
?>
<!DOCTYPE html>
<html >
<head>
<title> Bilder Galerie </title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<style type="text/css">
div#buttons{
position:absolute;
margin-left:-258px;
}
div#gHolder{
width: 1348px;
height: auto;
margin: 0 auto;
background-color: #FFA500;
padding: 10px;
position:fixed;
}
div#theBigImageHolder{
width: 0px;
height: 0px;
background-color: white;
}
div#thumbnailsHolder{
width: 393px;
height: 940px;
background-color: white;
margin: -8px 14px auto;
padding: 4px;
overflow: auto;
float: none;
}
div#Holder{
background-color: #FFA500;
width: 530px;
height: 960px;
float: right;
}
div#theBigImageHolder > img{
border: 15px solid #3e2b14;
width: 900px;
height: 917px;
/*margin: 71px 447px auto;*/
/*box-shadow: 0px 0px 3px 749px rgba(11, 12, 12, 0.95);*/
margin-top: -8px;
margin-left:422px;
top: 0;
left: 0;
right: 0;
bottom: 0;*/
}
div#thumbnailsHolder > img{
width: 90px;
height: 90px;
display: block;
float: left;
margin: 2px;
transition: border-radius 0.3s linear 0s;
overflow: auto;
}
div#thumbnailsHolder > img:hover{
border-radius: 100px;
cursor:pointer;
}
</style>
<script type ="text/javascript">
function imgFunc() {
var bigImage = document.getElementById("BigImage");
var thumbnailsHolder = document.getElementById("thumbnailsHolder");
thumbnailsHolder.addEventListener("click",function(event){
if (event.target.tagName == "IMG"){
bigImage.src = event.target.src;
}
},false);
}
window.addEventListener("load",imgFunc,false);
</script>
</head>
<body>
<div id ="gHolder">
<div id="theBigImageHolder">
<?php
echo '<img src="images/'.$my_images_arr[0].'" id="BigImage">';
?>
<!-- <img src="images/mench.jpg" id="BigImage"> -->
</div>
<div id="thumbnailsHolder">
<?php
echo $img_string;
?>
<!-- <img src="images/name1.jpg">
<img src="images/wolf.jpg">
<img src="images/panda.jpg">
<img src="images/hund.jpg">
-->
</div>
</div>
<div id="Holder">
<!-- <div id="buttons"> -->
<!-- <form action="upload.php" method="post" enctype="multipart/form-data"> -->
<!-- <p>Bitte eine Datei auswaehlen<br> -->
<!-- <input type="file" name="image"> <br> -->
<!-- <input type="submit" value="Hochladen"> -->
<!-- </form> -->
<!-- </div> -->
<center>
<br><br> <form action="upload.php" method="post" enctype="multipart/form-data">
Datei auswaehlen:<input type="file" name="image"><br /><br />
beschreibung:<input type="text" name="desc"><br /><br />
<input type="submit" name="upload" value="Hochladen">
</form>
</center>
</div>
</body>
</html>