Better handling for images

This commit is contained in:
Kasper Rynning-Tønnesen
2015-11-28 20:48:24 +01:00
parent ec97b4d8ef
commit 01526405f9
4 changed files with 33 additions and 39 deletions

View File

@@ -1,6 +1,6 @@
<?php <?php
$url = file_get_contents("https://img.youtube.com/vi/" . $_POST['id'] . "/mqdefault.jpg"); $url = file_get_contents("https://img.youtube.com/vi/".$_POST['id']."/mqdefault.jpg");
$image = new Imagick(); $image = new Imagick();
$image->readImageBlob($url); $image->readImageBlob($url);
@@ -10,9 +10,9 @@ $image->blurImage(30,50);
$output = $image->getimageblob(); $output = $image->getimageblob();
//$image->setImageFormat("jpeg"); $image->setImageFormat("jpeg");
//$image->imageWriteFile (fopen ("/static/images/thumbnails/".$_POST['id'].".jpg", "wb")); file_put_contents ("../static/images/thumbnails/".$_POST['id'].".jpg", $image);
echo base64_encode($output); echo base64_encode($output);
?> ?>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -121,15 +121,6 @@ var Nochan = {
if(Nochan.blob_list[i] !== undefined){ if(Nochan.blob_list[i] !== undefined){
//$(".room-namer").css("opacity", 0); //$(".room-namer").css("opacity", 0);
var img = new Image();
img.src = "/images/thumbnails/"+id+".jpg";
img.onerror = function(){ // Failed to load
console.log("didn't find");
};
img.onload = function(){ // Loaded successfully
console.log("found");
};
setTimeout(function(){ setTimeout(function(){
$("#mega-background").css("background", "url(data:image/png;base64,"+Nochan.blob_list[i]+")"); $("#mega-background").css("background", "url(data:image/png;base64,"+Nochan.blob_list[i]+")");
$("#mega-background").css("background-size" , "200%"); $("#mega-background").css("background-size" , "200%");
@@ -138,21 +129,16 @@ var Nochan = {
//$(".room-namer").css("opacity", 1); //$(".room-namer").css("opacity", 1);
},500); },500);
}else{ }else{
var img = new Image(); var img = new Image();
img.src = "/images/thumbnails/"+id+".jpg"; img.src = "/static/images/thumbnails/"+id+".jpg";
img.onerror = function(){ // Failed to load img.onerror = function(){ // Failed to load
console.log("didn't find");
};
img.onload = function(){ // Loaded successfully
console.log("found");
};
$.ajax({ $.ajax({
type: "POST", type: "POST",
data: {id:id}, data: {id:id},
url: "/php/imageblob.php", url: "/php/imageblob.php",
success: function(data){ success: function(data){
console.log(data);
Nochan.blob_list.push(data); Nochan.blob_list.push(data);
//data will contain the vote count echoed by the controller i.e. //data will contain the vote count echoed by the controller i.e.
//$(".room-namer").css("opacity", 0); //$(".room-namer").css("opacity", 0);
@@ -168,6 +154,14 @@ var Nochan = {
} }
}); });
};
img.onload = function(){ // Loaded successfully
$("#mega-background").css("background", "url("+img.src+")");
$("#mega-background").css("background-size" , "200%");
$("#mega-background").css("opacity", 1);
$("#search").attr("placeholder", list[i][3]);
};
} }
setTimeout(function(){ setTimeout(function(){
Nochan.add_backdrop(list, i+1); Nochan.add_backdrop(list, i+1);