No Thumbnail After Changing Server In External Pictures »  Show posts from    to     

Icy Phoenix


Old Support Topics - No Thumbnail After Changing Server In External Pictures



Danielc [ Thu 06 Aug, 2009 14:24 ]
Post subject: No Thumbnail After Changing Server In External Pictures
Hello everybody..
After i changed my server, i get "No Thumbnail" on every image that i post, but not in pictures that i uploaded to my page..
What can i do?


spydie [ Thu 06 Aug, 2009 14:26 ]
Post subject: Re: No Thumbnail After Changing Server In External Pictures
have you cleared your cache ??


DWho [ Thu 06 Aug, 2009 14:30 ]
Post subject: Re: No Thumbnail After Changing Server In External Pictures
Also some hosts have blocked thumbnail images that are uploaded by the upload image mod in posts... It brings up an exploit or something ... though it is not a security issue it is just the way some hosts have set up there servers...

My host was the same and after I explained exactly what was going on they changed my set up so it worked, though every new site i up they have to do it again for that site...

Hope that helps...



Danielc [ Thu 06 Aug, 2009 14:33 ]
Post subject: Re: No Thumbnail After Changing Server In External Pictures
Yeah, the main directory...
I didn't delete the images... The previous images are shown perfectly, but not the new images..
@ DWho: Thanks for the answer. I think its a server problem, but there isn't a solution without talking with them? Why my uploaded images work perfectly?

---
EDIT:
I think i know what is the problem.. The problem is the function allow_url_fopen. It is disabled in byethost for free users..
I tried to use .htaccess to enable it but it didn't work.. I want to know if there is a method to download the image from the url, upload it to my forum, generate the thumbnail, and delete the original image without doing it manually..


Danielc [ Fri 07 Aug, 2009 23:02 ]
Post subject: Re: No Thumbnail After Changing Server In External Pictures
No body knows???
I'm trying to make a code in the image_thumbnail.php file to upload the file first to my server, with this:
Code: [Hide]
  1. $grab = curl_init();  
  2. $tmppath = $_SERVER['DOCUMENT_ROOT'] . "/tmp/";  
  3. curl_setopt($grab, CURLOPT_URL, $pic_fullpath);  
  4. curl_setopt($grab, CURLOPT_HEADER, false);  
  5. curl_setopt($grab, CURLOPT_RETURNTRANSFER, true);  
  6. $grabbed = curl_exec($grab);  
  7. curl_close($grab);  
  8. $filename = strtolower(md5((rand() * time()).$_SERVER['REMOTE_ADDR']) . "." . $pic_filetype);  
  9. $file = fopen($tmppath.$filename, 'w');  
  10. fwrite($file, $grabbed);  
  11. fclose($file);  
  12.  
  13. $pic_id = $tmppath . $filename;  
  14. $pic_fullpath = $tmppath . $filename;  
  15. $pic_fullpath = str_replace(array(' '), array('%20'), $pic_id);  
  16. $pic_id = str_replace('http://', '', str_replace('https://', '', $pic_id));  
  17. $archivo = fopen("texto.txt","w");  
  18. fwrite($archivo, $pic_fullpath . " " . $pic_id . PHP_EOL);  
  19.  
  20. $pic_path[] = array();  
  21. $pic_path = explode('/', $pic_id);  
  22. $pic_filename = $pic_path[count($pic_path) - 1];  
  23. $file_part = explode('.', strtolower($pic_filename));  
  24. $pic_filetype = $file_part[count($file_part) - 1];  
  25. fwrite($archivo, "El nombre del archivo es $pic_filename y su extension es $pic_filetype" . PHP_EOL);  
  26.  
  27. @chmod($tmppath.$filename, 0777); 

But i can't get it work... Pleaseeeeeeeeeeee Help me!!!
What's the difference between the "uploader" of "upload.php" and my code?

Please help me!


spydie [ Fri 07 Aug, 2009 23:08 ]
Post subject: Re: No Thumbnail After Changing Server In External Pictures
What about an pseudo php.ini file ???


Danielc [ Fri 07 Aug, 2009 23:55 ]
Post subject: Re: No Thumbnail After Changing Server In External Pictures
MMM How i make it? I tried using htaccess to enable allow_url_fopen, but it doesn't work...


Lopalong [ Sat 08 Aug, 2009 03:22 ]
Post subject: Re: No Thumbnail After Changing Server In External Pictures
Danielc wrote: [View Post]

But i can't get it work... Pleaseeeeeeeeeeee Help me!!!


There are lot's of free hosts that don't work with Icy Phoenix in one way or another because they block certain aspects of their service.

And support here in my opinion should be for Icy Phoenix related problems and not server / host issues, So I recommend that you change host's until you find one that doesn't limit what they provide.


Danielc [ Sat 08 Aug, 2009 07:13 ]
Post subject: Re: No Thumbnail After Changing Server In External Pictures
I don't think that it's a good idea t change hosting... I use free hosting and so, i cannot take so much risks with my page, until i get a payment method to pay a paid hosting...
I understand that this isn't a problem directly with Icy Phoenix. I understand that all of you do this in your free time, without any payment. This is why i'm investigating and trying to get it working, and i'm near from the solution (i think). I was investigating a script that works in my server, i found some curl based script, i tried to "port" to Icy Phoenix, with bad results, i did some modifications to the script, so now, i think its easier to "port".. This is the result:
Code: [Hide] [Select]
<?php

///////////////////////////////////
// COPYRIGHT VOIDET
// IF YOU USE THIS DONT REMOVE THIS
// WWW.JOTLAB.COM
///////////////////////////////////

//////////////////////////////////
// Modifications By Danielc
// Now Generates the image in real
// time and adds some functions
//////////////////////////////////
$srcurl = (isset($_GET['srcurl']) ? $_GET['srcurl'] : (isset($_POST['srcurl']) ? $_POST['srcurl'] : "Sin imagen"));
$srcurl = urldecode($srcurl);

if(strlen($srcurl) > 0){
$acceptedfiletypes = array('.jpg', '.gif', '.png', '.jpeg');
$src_path[] = array();
$src_path = explode('/', $srcurl);
$src_filename = $src_path[count($src_path) - 1];
$filetype = strtolower(strrchr($srcurl, '.'));

if(in_array($filetype, $acceptedfiletypes)){


$default_max_size = 400;
$maxsize = (isset($_GET['maxsize'])) ? $_GET['maxsize'] : $default_max_size;
$maxsize = (($maxsize > 600) || ($maxsize < 30)) ? $default_max_size : $maxsize;

//ECHO "<b>DEBUG: maxsize = $maxsize </b> </br>";
$tmppath = $_SERVER['DOCUMENT_ROOT'] . '/tmp/';
$thumbspath = $_SERVER['DOCUMENT_ROOT'] . '/files/thumbs/';
$urltothumbs = 'http://danielc.22web.net/files/thumbs/';
$pic_thumbnail_prefix = 'mid_' . (($maxsize != $default_max_size) ? ($maxsize . '_') : '') . md5($srcurl);
$showoriginalsize = (isset($_GET['showoriginalsize'])) ? $_GET['showoriginalsize'] : 0;

$filename = $pic_thumbnail_prefix . '_' . $src_filename;
if(file_exists($thumbspath.$filename)){
unlink($thumbspath.$filename);
//ECHO "<b>DEBUG: Existencia de archivo previo. Eliminando.</b> </br>";
}

$grab = curl_init();
curl_setopt($grab, CURLOPT_URL, $srcurl);
curl_setopt($grab, CURLOPT_HEADER, false);
curl_setopt($grab, CURLOPT_RETURNTRANSFER, true);
$grabbed = curl_exec($grab);
curl_close($grab);
//ECHO "<b>DEBUG: Nombre de archivo = $filename</b> </br>";
$file = fopen($tmppath.$filename, 'w');
fwrite($file, $grabbed);
fclose($file);

if(file_exists($tmppath.$filename)){
//ECHO "<b>DEBUG: Archivo Subido correctamente a directorio temporal.</b> </br>";

switch ($filetype){
case '.jpg':
$srcimage = imagecreatefromjpeg($tmppath.$filename);
//header("Content-type: image/jpeg");
break;
case '.jpeg':
$srcimage = imagecreatefromjpeg($tmppath.$filename);
//header("Content-type: image/jpeg");
break;
case '.gif':
$srcimage = imagecreatefromgif($tmppath.$filename);
//header("Content-type: image/gif");
break;
case '.png':
$srcimage = imagecreatefrompng($tmppath.$filename);
//header("Content-type: image/png");
break;
default:
$srcimage = imagecreatefromjpeg($tmppath.$filename);
//header("Content-type: image/jpeg");
}

$srcimagex = imagesx($srcimage);
$srcimagey = imagesy($srcimage);

if($srcimagex > $maxsize || $srcimagey > $maxsize){
if($srcimagex > $srcimagey){
$ratio = $maxsize / $srcimagex;
} else {
$ratio = $maxsize / $srcimagey;
}


//next calculate the size of the thumbnail
$thumbwidth = $srcimagex * $ratio;
$thumbheight = $srcimagey * $ratio;
} else {
$thumbwidth = $srcimagex;
$thumbheight = $srcimagey;
}
//ECHO "<b>DEBUG: Las dimensiones calculadas de la miniatura son " . $thumbwidth . "x" . $thumbheight . "</b> </br>";
if($showoriginalsize == 0){
$thumbnail = imagecreatetruecolor($thumbwidth, $thumbheight);
//ECHO "<b>DEBUG: Showoriginalsize deshabilitado</b></br>";
} else {
//ECHO "<b>DEBUG: Showoriginalsize habilitado</b></br>";

$thumbnail = imagecreatetruecolor($thumbwidth, $thumbheight + 20);
$color = ImageColorAllocate($thumbnail, 0, 0, 0);
imagefilledrectangle($thumbnail, 0, $thumbheight, $thumbwidth, $thumbheight + 20, $color);
$color_texto = ImageColorAllocate($thumbnail, 255, 255, 255);
$texto = $srcimagex . "x" . $srcimagey;
//ECHO "<b>DEBUG: texto = $texto</b></br>";
$fuente = $_SERVER['DOCUMENT_ROOT'] . '/images/fonts/denmark.ttf';
$bounds[] = array();
$bounds = imageftbbox(10,0,$fuente, $texto);
$x = $bounds[0] + ($thumbwidth / 2) - ($bounds[4] / 2);
$y = $bounds[1] + (20 / 2) - ($bounds[5] / 2) + $thumbheight;

//ECHO "<b>DEBUG: x = $x y = $y </b></br>";

imagettftext($thumbnail, 10, 0, $x, $y, $color_texto, $fuente, $texto);
}

imagecopyresampled($thumbnail, $srcimage, 0, 0, 0, 0, $thumbwidth, $thumbheight, $srcimagex, $srcimagey);
header('Content-type: image/jpeg');
imagejpeg($thumbnail);
imagejpeg($thumbnail, $thumbspath.$filename, 75);
imagedestroy($thumbnail);
unlink($tmppath.$filename);
} else {
//ECHO "<b>DEBUG: No se ha subido correctamente el archivo.</b></br>";
}
} else {
//This file was never an image, AND WILL NEVER BE AN IMAGE!
//echo 'El archivo no es una imagen.';
}
} else {
//ECHO "Primera condicion incumplida";
}

?>


This can be tested here: http://www.danielc.22web.net/thumbcurl_auto.php
To generate a thumbnail just pass the parameter srcurl with the url of the image..
You can change the size of the thumbnail with the parameter maxsize (by default 400) and you can add the original size in the bottom passing the parameter showoriginalsize=1
Example: http://www.danielc.22web.net/thumbc...woriginalsize=1

Sorry for the "echos" but i used those for testing.. Now, i need help to replace it with the image_thumbnail.php code. I will try that tomorrow, but any help is well...

Thanks


spydie [ Sat 08 Aug, 2009 11:46 ]
Post subject: Re: No Thumbnail After Changing Server In External Pictures
Danielc

have a look here or here . maybe you find something interessting.


Danielc [ Sat 08 Aug, 2009 20:36 ]
Post subject: Re: No Thumbnail After Changing Server In External Pictures
I solved it!!!!!!!!!!!!!!!!!!!!!!!!! I modified image_thumbnail.php file with some changes in my file.

This is the solution:

¿What will you need?:

- A folder in the root of your web called tmp (you can change it in the modified file)
- A folder in the root of your web called fuentes (you can change it in the modified file)
- True type font segoeuib.ttf, in fuentes folder (you can change it in the modified file)
- Icy Phoenix
- These instructions:

Instructions:

Code: [Hide] [Select]
#
#-------------[ Begin ]-----------
#

#
#------------[ OPEN ]--------------
#

/image_thumbnail.php

#
#-------------[ FIND]--------------
#

require(ALBUM_MOD_PATH . 'album_image_class.' . PHP_EXT);

#
#-------------[ AFTER ADD ] ----------
#

//Danielc's MOD - Vars Declaration START
$tmppath = $_SERVER['DOCUMENT_ROOT'] . '/tmp/'; // You must have this dir in the root.
$thumbspath = $_SERVER['DOCUMENT_ROOT'] . '/files/thumbs/'; // The thumbs directory
$urltothumbs = 'http://www.danielc.22web.net/files/thumbs/'; // The URL to thumbs directory
//Danielc's MOD - Vars Declaration END

#
#-------------[ FIND]--------------
#

if ($image_processed == false)
{

#
#-------------[ AFTER ADD ] ----------
#

// Danielc's Mod Start
$filename = $pic_thumbnail_prefix . '_' . $pic_filename;
$grab = curl_init();
curl_setopt($grab, CURLOPT_URL, $pic_fullpath);
curl_setopt($grab, CURLOPT_HEADER, false);
curl_setopt($grab, CURLOPT_RETURNTRANSFER, true);
$grabbed = curl_exec($grab);
curl_close($grab);
//ECHO "<b>DEBUG: Nombre de archivo = $filename</b> </br>";
$file = fopen($tmppath.$filename, 'w');
fwrite($file, $grabbed);
fclose($file);
$pic_fullpath = $tmppath . $filename;
fwrite($log, "pic_fullpath = $pic_fullpath" . PHP_EOL);
$pic_local = true;
//Danielc's Mod END

#
#-------------[ FIND]--------------
#


if ($pic_width > $pic_height)
{
$thumbnail_width = $board_config['thumbnail_size'];
$thumbnail_height = $board_config['thumbnail_size'] * ($pic_height / $pic_width);
}
else
{
$thumbnail_height = $board_config['thumbnail_size'];
$thumbnail_width = $board_config['thumbnail_size'] * ($pic_width / $pic_height);
}

$Image = new ImgObj();

if ($pic_filetype == 'jpg')
{
$Image->ReadSourceFileJPG($pic_fullpath);
}
else
{
$Image->ReadSourceFile($pic_fullpath);
}

$Image->Resize($thumbnail_width, $thumbnail_height);

if( $board_config['show_pic_size_on_thumb'] == 1)
{
$dimension_string = intval($pic_width) . "x" . intval($pic_height) . "(" . intval(filesize($pic_fullpath)/1024) . "KB)";
$Image->Text($dimension_string);
}

if ($board_config['thumbnail_cache'] == true)
{
if ($pic_filetype == 'jpg')
{
$Image->SendToFileJPG($pic_thumbnail_fullpath, $album_config['thumbnail_quality']);
}
else
{
$Image->SendToFile($pic_thumbnail_fullpath, $album_config['thumbnail_quality']);
}
//$Image->SendToFile($pic_thumbnail_fullpath, $board_config['thumbnail_quality']);
//@chmod($pic_thumbnail_fullpath, 0777);
}

if ($pic_filetype == 'jpg')
{
$Image->SendToBrowserJPG($pic_title_reg, $pic_filetype, 'thumb_', '', $board_config['thumbnail_quality']);
}
else
{
$Image->SendToBrowser($pic_title_reg, $pic_filetype, 'thumb_', '', $board_config['thumbnail_quality']);
}

if ($Image == true)
{
$Image->Destroy();
exit;
}
else
{
$Image->Destroy();
header('Content-type: image/jpeg');
header('Content-Disposition: filename=thumb_' . $pic_title_reg . '.' . $pic_filetype);
readfile($images['no_thumbnail']);
exit;
}

#
#-------------[ REPLACE WITH ]--------------
#

//---------------------------------
//Danielc's CURL MOD START
//---------------------------------

$maxsize = $req_thumb_size;

$showoriginalsize = $board_config['show_pic_size_on_thumb'];
$jpgquality = $board_config['thumbnail_quality'];
$filename = $pic_thumbnail_prefix . '_' . $pic_filename;
/*if(file_exists($thumbspath.$filename)){
unlink($thumbspath.$filename);
//ECHO "<b>DEBUG: Existencia de archivo previo. Eliminando.</b> </br>";
}*/

if(file_exists($tmppath.$filename)){
//ECHO "<b>DEBUG: Archivo Subido correctamente a directorio temporal.</b> </br>";

switch ($pic_filetype){
case 'jpg':
$srcimage = imagecreatefromjpeg($tmppath.$filename);
//header("Content-type: image/jpeg");
break;
case 'jpeg':
$srcimage = imagecreatefromjpeg($tmppath.$filename);
//header("Content-type: image/jpeg");
break;
case 'gif':
$srcimage = imagecreatefromgif($tmppath.$filename);
//header("Content-type: image/gif");
break;
case 'png':
$srcimage = imagecreatefrompng($tmppath.$filename);
//header("Content-type: image/png");
break;
default:
$srcimage = imagecreatefromjpeg($tmppath.$filename);
//header("Content-type: image/jpeg");
}

$pic_width = imagesx($srcimage);
$pic_height = imagesy($srcimage);

if($pic_width > $maxsize || $pic_height > $maxsize){
if($pic_width > $pic_height){
$ratio = $maxsize / $pic_width;
} else {
$ratio = $maxsize / $pic_height;
}


//next calculate the size of the thumbnail
$thumbnail_width = $pic_width * $ratio;
$thumbnail_height = $pic_height * $ratio;
} else {
$thumbnail_width = $pic_width;
$thumbnail_height = $pic_height;
}
//ECHO "<b>DEBUG: Las dimensiones calculadas de la miniatura son " . $thumbwidth . "x" . $thumbheight . "</b> </br>";
if($showoriginalsize == 0){
$thumbnail = imagecreatetruecolor($thumbnail_width, $thumbnail_height);
//ECHO "<b>DEBUG: Showoriginalsize deshabilitado</b></br>";
} else {
//ECHO "<b>DEBUG: Showoriginalsize habilitado</b></br>";

$thumbnail = imagecreatetruecolor($thumbnail_width, $thumbnail_height + 20);
$color = ImageColorAllocate($thumbnail, 0, 0, 0);
imagefilledrectangle($thumbnail, 0, $thumbnail_height, $thumbnail_width, $thumbnail_height + 20, $color);
$color_texto = ImageColorAllocate($thumbnail, 255, 255, 255);
$peso = filesize($tmppath.$filename);
$texto = $pic_width . "x" . $pic_height . "px " . round(($peso/1024)) . " KB";
//ECHO "<b>DEBUG: texto = $texto</b></br>";
$fuente = $_SERVER['DOCUMENT_ROOT'] . '/fuentes/segoeuib.ttf';
$bounds[] = array();
$bounds = imageftbbox(10,0,$fuente, $texto);
$x = $bounds[0] + ($thumbnail_width / 2) - ($bounds[4] / 2);
$y = $bounds[1] + (20 / 2) - ($bounds[5] / 2) + $thumbnail_height;

//ECHO "<b>DEBUG: x = $x y = $y </b></br>";

imagettftext($thumbnail, 10, 0, $x, $y, $color_texto, $fuente, $texto);
}

imagecopyresampled($thumbnail, $srcimage, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $pic_width, $pic_height);

switch ($pic_filetype) {
case "jpg":
case "jpeg":
header('Content-type: image/jpeg');
imagejpeg($thumbnail);
imagejpeg($thumbnail, $thumbspath.$filename, $jpgquality);
break;
case "gif":
header('Content-type: image/gif');
imagegif($thumbnail);
imagegif($thumbnail, $thumbspath.$filename);
break;
case "png":
header('Content-type: image/png');
imagepng($thumbnail);
imagepng($thumbnail, $thumbspath.$filename);
break;
default:
header('Content-type: image/jpeg');
imagejpeg($thumbnail);
imagejpeg($thumbnail, $thumbspath.$filename, $jpgquality);
}
@chmod($thumbspath.$filename, 0777);
imagedestroy($thumbnail);
unlink($tmppath.$filename);
}
//---------------------------------
//Danielc's CURL MOD END
//---------------------------------

#
#----------------[ SAVE ] ----------
#



DWho [ Wed 12 Aug, 2009 17:41 ]
Post subject: Re: [SOLVED] No Thumbnail After Changing Server In External Pictures
nice thanks for sharing has anyone else tested this... so we know it works out of the box

and then I will move to customisations



Danielc [ Thu 13 Aug, 2009 01:21 ]
Post subject: Re: [SOLVED] No Thumbnail After Changing Server In External Pictures
In that code, there is a problem with the local pictures..

¿What will you need?:

- A folder in the root of your web called tmp (you can change it in the modified file)
- A folder in the root of your web called fuentes (you can change it in the modified file)
- True type font segoeuib.ttf, in fuentes folder (you can change it in the modified file)
- Icy Phoenix
- These instructions:

Instructions:

Code: [Hide] [Select]
#
#-------------[ Begin ]-----------
#

#
#------------[ OPEN ]--------------
#

/image_thumbnail.php

#
#-------------[ FIND]--------------
#

require(ALBUM_MOD_PATH . 'album_image_class.' . PHP_EXT);

#
#-------------[ AFTER ADD ] ----------
#

//Danielc's MOD - Vars Declaration START
$tmppath = $_SERVER['DOCUMENT_ROOT'] . '/tmp/'; // You must have this dir in the root.
$thumbspath = $_SERVER['DOCUMENT_ROOT'] . '/files/thumbs/'; // The thumbs directory
$urltothumbs = 'http://www.danielc.22web.net/files/thumbs/'; // The URL to thumbs directory
//Danielc's MOD - Vars Declaration END

#
#-------------[ FIND]--------------
#

if ($image_processed == false)
{

#
#-------------[ AFTER ADD ] ----------
#

// Danielc's Mod Start
$filename = $pic_thumbnail_prefix . '_' . $pic_filename;
if ($pic_local == true){
copy($pic_fullpath, $tmppath.$filename);

} else {
$grab = curl_init();
curl_setopt($grab, CURLOPT_URL, $pic_fullpath);
curl_setopt($grab, CURLOPT_HEADER, false);
curl_setopt($grab, CURLOPT_RETURNTRANSFER, true);
$grabbed = curl_exec($grab);
curl_close($grab);
//ECHO "<b>DEBUG: Nombre de archivo = $filename</b> </br>";
$file = fopen($tmppath.$filename, 'w');
fwrite($file, $grabbed);
fclose($file);

}

$pic_fullpath = $tmppath . $filename;
$pic_local = true;
//Danielc's Mod END

#
#-------------[ FIND]--------------
#


if ($pic_width > $pic_height)
{
$thumbnail_width = $board_config['thumbnail_size'];
$thumbnail_height = $board_config['thumbnail_size'] * ($pic_height / $pic_width);
}
else
{
$thumbnail_height = $board_config['thumbnail_size'];
$thumbnail_width = $board_config['thumbnail_size'] * ($pic_width / $pic_height);
}

$Image = new ImgObj();

if ($pic_filetype == 'jpg')
{
$Image->ReadSourceFileJPG($pic_fullpath);
}
else
{
$Image->ReadSourceFile($pic_fullpath);
}

$Image->Resize($thumbnail_width, $thumbnail_height);

if( $board_config['show_pic_size_on_thumb'] == 1)
{
$dimension_string = intval($pic_width) . "x" . intval($pic_height) . "(" . intval(filesize($pic_fullpath)/1024) . "KB)";
$Image->Text($dimension_string);
}

if ($board_config['thumbnail_cache'] == true)
{
if ($pic_filetype == 'jpg')
{
$Image->SendToFileJPG($pic_thumbnail_fullpath, $album_config['thumbnail_quality']);
}
else
{
$Image->SendToFile($pic_thumbnail_fullpath, $album_config['thumbnail_quality']);
}
//$Image->SendToFile($pic_thumbnail_fullpath, $board_config['thumbnail_quality']);
//@chmod($pic_thumbnail_fullpath, 0777);
}

if ($pic_filetype == 'jpg')
{
$Image->SendToBrowserJPG($pic_title_reg, $pic_filetype, 'thumb_', '', $board_config['thumbnail_quality']);
}
else
{
$Image->SendToBrowser($pic_title_reg, $pic_filetype, 'thumb_', '', $board_config['thumbnail_quality']);
}

if ($Image == true)
{
$Image->Destroy();
exit;
}
else
{
$Image->Destroy();
header('Content-type: image/jpeg');
header('Content-Disposition: filename=thumb_' . $pic_title_reg . '.' . $pic_filetype);
readfile($images['no_thumbnail']);
exit;
}

#
#-------------[ REPLACE WITH ]--------------
#

//---------------------------------
//Danielc's CURL MOD START
//---------------------------------

$maxsize = $req_thumb_size;

$showoriginalsize = $board_config['show_pic_size_on_thumb'];
$jpgquality = $board_config['thumbnail_quality'];
$filename = $pic_thumbnail_prefix . '_' . $pic_filename;
/*if(file_exists($thumbspath.$filename)){
unlink($thumbspath.$filename);
//ECHO "<b>DEBUG: Existencia de archivo previo. Eliminando.</b> </br>";
}*/

if(file_exists($tmppath.$filename)){
//ECHO "<b>DEBUG: Archivo Subido correctamente a directorio temporal.</b> </br>";

switch ($pic_filetype){
case 'jpg':
$srcimage = imagecreatefromjpeg($tmppath.$filename);
//header("Content-type: image/jpeg");
break;
case 'jpeg':
$srcimage = imagecreatefromjpeg($tmppath.$filename);
//header("Content-type: image/jpeg");
break;
case 'gif':
$srcimage = imagecreatefromgif($tmppath.$filename);
//header("Content-type: image/gif");
break;
case 'png':
$srcimage = imagecreatefrompng($tmppath.$filename);
//header("Content-type: image/png");
break;
default:
$srcimage = imagecreatefromjpeg($tmppath.$filename);
//header("Content-type: image/jpeg");
}

$pic_width = imagesx($srcimage);
$pic_height = imagesy($srcimage);

if($pic_width > $maxsize || $pic_height > $maxsize){
if($pic_width > $pic_height){
$ratio = $maxsize / $pic_width;
} else {
$ratio = $maxsize / $pic_height;
}


//next calculate the size of the thumbnail
$thumbnail_width = $pic_width * $ratio;
$thumbnail_height = $pic_height * $ratio;
} else {
$thumbnail_width = $pic_width;
$thumbnail_height = $pic_height;
}
//ECHO "<b>DEBUG: Las dimensiones calculadas de la miniatura son " . $thumbwidth . "x" . $thumbheight . "</b> </br>";
if($showoriginalsize == 0){
$thumbnail = imagecreatetruecolor($thumbnail_width, $thumbnail_height);
//ECHO "<b>DEBUG: Showoriginalsize deshabilitado</b></br>";
} else {
//ECHO "<b>DEBUG: Showoriginalsize habilitado</b></br>";

$thumbnail = imagecreatetruecolor($thumbnail_width, $thumbnail_height + 20);
$color = ImageColorAllocate($thumbnail, 0, 0, 0);
imagefilledrectangle($thumbnail, 0, $thumbnail_height, $thumbnail_width, $thumbnail_height + 20, $color);
$color_texto = ImageColorAllocate($thumbnail, 255, 255, 255);
$peso = filesize($tmppath.$filename);
$texto = $pic_width . "x" . $pic_height . "px " . round(($peso/1024)) . " KB";
//ECHO "<b>DEBUG: texto = $texto</b></br>";
$fuente = $_SERVER['DOCUMENT_ROOT'] . '/fuentes/segoeuib.ttf';
$bounds[] = array();
$bounds = imageftbbox(10,0,$fuente, $texto);
$x = $bounds[0] + ($thumbnail_width / 2) - ($bounds[4] / 2);
$y = $bounds[1] + (20 / 2) - ($bounds[5] / 2) + $thumbnail_height;

//ECHO "<b>DEBUG: x = $x y = $y </b></br>";

imagettftext($thumbnail, 10, 0, $x, $y, $color_texto, $fuente, $texto);
}

imagecopyresampled($thumbnail, $srcimage, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $pic_width, $pic_height);

switch ($pic_filetype) {
case "jpg":
case "jpeg":
header('Content-type: image/jpeg');
imagejpeg($thumbnail);
imagejpeg($thumbnail, $thumbspath.$filename, $jpgquality);
break;
case "gif":
header('Content-type: image/gif');
imagegif($thumbnail);
imagegif($thumbnail, $thumbspath.$filename);
break;
case "png":
header('Content-type: image/png');
imagepng($thumbnail);
imagepng($thumbnail, $thumbspath.$filename);
break;
default:
header('Content-type: image/jpeg');
imagejpeg($thumbnail);
imagejpeg($thumbnail, $thumbspath.$filename, $jpgquality);
}
@chmod($thumbspath.$filename, 0777);
imagedestroy($thumbnail);
unlink($tmppath.$filename);
}
//---------------------------------
//Danielc's CURL MOD END
//---------------------------------

#
#----------------[ SAVE ] ----------
#



With this, if source picture is in the server, the script will copy the picture to the temporal folder, after it generates the thumbnail and deletes it..




Powered by Icy Phoenix