https://www.icyphoenix.com/viewtopic.php?f=35&t=6238 ----------------------------------- Danielc Thu 06 Aug, 2009 14:24 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 Re: No Thumbnail After Changing Server In External Pictures ----------------------------------- have you cleared your cache ?? ----------------------------------- DWho Thu 06 Aug, 2009 14:30 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... :mrgreen: :mrgreen: ----------------------------------- Danielc Thu 06 Aug, 2009 14:33 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 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]$grab = curl_init(); $tmppath = $_SERVER['DOCUMENT_ROOT'] . "/tmp/"; 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); $filename = strtolower(md5((rand() * time()).$_SERVER['REMOTE_ADDR']) . "." . $pic_filetype); $file = fopen($tmppath.$filename, 'w'); fwrite($file, $grabbed); fclose($file); $pic_id = $tmppath . $filename; $pic_fullpath = $tmppath . $filename; $pic_fullpath = str_replace(array(' '), array('%20'), $pic_id); $pic_id = str_replace('http://', '', str_replace('https://', '', $pic_id)); $archivo = fopen("texto.txt","w"); fwrite($archivo, $pic_fullpath . " " . $pic_id . PHP_EOL); $pic_path[] = array(); $pic_path = explode('/', $pic_id); $pic_filename = $pic_path[count($pic_path) - 1]; $file_part = explode('.', strtolower($pic_filename)); $pic_filetype = $file_part[count($file_part) - 1]; fwrite($archivo, "El nombre del archivo es $pic_filename y su extension es $pic_filetype" . PHP_EOL); @chmod($tmppath.$filename, 0777);[/code] 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 Re: No Thumbnail After Changing Server In External Pictures ----------------------------------- What about an pseudo php.ini file ??? ----------------------------------- Danielc Fri 07 Aug, 2009 23:55 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 Re: No Thumbnail After Changing Server In External Pictures ----------------------------------- [quote user="Danielc" post="42448"] But i can't get it work... Pleaseeeeeeeeeeee Help me!!![/quote] 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. :P ----------------------------------- Danielc Sat 08 Aug, 2009 07:13 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 linenumbers=false] 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 "DEBUG: maxsize = $maxsize
"; $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 "DEBUG: Existencia de archivo previo. Eliminando.
"; } $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 "DEBUG: Nombre de archivo = $filename
"; $file = fopen($tmppath.$filename, 'w'); fwrite($file, $grabbed); fclose($file); if(file_exists($tmppath.$filename)){ //ECHO "DEBUG: Archivo Subido correctamente a directorio temporal.
"; 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 "DEBUG: Las dimensiones calculadas de la miniatura son " . $thumbwidth . "x" . $thumbheight . "
"; if($showoriginalsize == 0){ $thumbnail = imagecreatetruecolor($thumbwidth, $thumbheight); //ECHO "DEBUG: Showoriginalsize deshabilitado
"; } else { //ECHO "DEBUG: Showoriginalsize habilitado
"; $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 "DEBUG: texto = $texto
"; $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 "DEBUG: x = $x y = $y
"; 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 "DEBUG: No se ha subido correctamente el archivo.
"; } } 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"; } ?>[/code] 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/thumbcurl_auto.php?srcurl=http://imagenes.blogocio.net/grande/20090804_00080.jpg&maxsize=300&showoriginalsize=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 Re: No Thumbnail After Changing Server In External Pictures ----------------------------------- Danielc have a look [url=http://www.strato-alojamiento.es/hosting/hosting_packages/index.html]here or [url=http://alta.1and1.es/xml/order/Hosting;jsessionid=017B7D269E425592DBFDE336F9F3E5DF.TC31b?ac=OM.WE.WE861K13432T7073a]here . maybe you find something interessting. ----------------------------------- Danielc Sat 08 Aug, 2009 20:36 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 [b]tmp[/b] (you can change it in the modified file) - A folder in the root of your web called [b]fuentes[/b] (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 :mrblue: - These instructions: [b]Instructions:[/b] [code linenumbers=false] # #-------------[ 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 "DEBUG: Nombre de archivo = $filename
"; $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 "DEBUG: Existencia de archivo previo. Eliminando.
"; }*/ if(file_exists($tmppath.$filename)){ //ECHO "DEBUG: Archivo Subido correctamente a directorio temporal.
"; 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 "DEBUG: Las dimensiones calculadas de la miniatura son " . $thumbwidth . "x" . $thumbheight . "
"; if($showoriginalsize == 0){ $thumbnail = imagecreatetruecolor($thumbnail_width, $thumbnail_height); //ECHO "DEBUG: Showoriginalsize deshabilitado
"; } else { //ECHO "DEBUG: Showoriginalsize habilitado
"; $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 "DEBUG: texto = $texto
"; $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 "DEBUG: x = $x y = $y
"; 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 ] ---------- # [/code] ----------------------------------- DWho Wed 12 Aug, 2009 17:41 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 :mrgreen: :mrgreen: ----------------------------------- Danielc Thu 13 Aug, 2009 01:21 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 [b]tmp[/b] (you can change it in the modified file) - A folder in the root of your web called [b]fuentes[/b] (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 :mrblue: - These instructions: [b]Instructions:[/b] [code linenumbers=false] # #-------------[ 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 "DEBUG: Nombre de archivo = $filename
"; $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 "DEBUG: Existencia de archivo previo. Eliminando.
"; }*/ if(file_exists($tmppath.$filename)){ //ECHO "DEBUG: Archivo Subido correctamente a directorio temporal.
"; 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 "DEBUG: Las dimensiones calculadas de la miniatura son " . $thumbwidth . "x" . $thumbheight . "
"; if($showoriginalsize == 0){ $thumbnail = imagecreatetruecolor($thumbnail_width, $thumbnail_height); //ECHO "DEBUG: Showoriginalsize deshabilitado
"; } else { //ECHO "DEBUG: Showoriginalsize habilitado
"; $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 "DEBUG: texto = $texto
"; $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 "DEBUG: x = $x y = $y
"; 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 ] ---------- # [/code] 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..