https://www.icyphoenix.com/viewtopic.php?f=35&t=6541 ----------------------------------- Danielc Fri 09 Oct, 2009 17:01 Problems Generating Some Thumbnails ----------------------------------- Hello everybody... I have problems generating some thumbnails of images that exists... For example, yesterday i coded one php to show the torunament ranking of an user.. But my site can't generate the thumbnail, and the image is perfectly... For example: [img]http://www.rankings.miiconsola.com/Danielc.jpg[/img] If you click in the image, you can see it perfectly, but the thumbnail isn't generated well.. Could you help me please? EDIT: Link corrected. ----------------------------------- Mighty Gorgon Sat 10 Oct, 2009 13:11 Re: Problems Generating Some Thumbnails ----------------------------------- Image address contains special characters and for security reason Thumbnail is not generated... ----------------------------------- Danielc Sat 10 Oct, 2009 15:36 Re: Problems Generating Some Thumbnails ----------------------------------- So, isn't there a way that i can generate the thumbnail?? Thanks for the answer.. ----------------------------------- Mighty Gorgon Sun 11 Oct, 2009 10:33 Re: Problems Generating Some Thumbnails ----------------------------------- Yes, there is... but you will lose your warranty against hackers... do you want to proceed? :P ----------------------------------- Danielc Sun 11 Oct, 2009 16:05 Re: Problems Generating Some Thumbnails ----------------------------------- I have done one thing.. Can you tell me if that thing is secure? I created a new folder with my file (called ranking.php). In that folder, i have created a .htaccess file, copying some parts of the one in the root. Also, i have written a rule to redirect, for example, "http://www.rankings.miiconsola.com/santiago marine.jpg" to my file with the correct parameters.. In rankings.php, i generate manually the thumbnails and copy them to the correct folder.. Is this secure?? Do yo need to see the php file? Thanks!!! ----------------------------------- Informpro Sun 11 Oct, 2009 16:18 Re: Problems Generating Some Thumbnails ----------------------------------- Why not remove the space x) ? ----------------------------------- Danielc Sun 11 Oct, 2009 16:43 Re: Problems Generating Some Thumbnails ----------------------------------- ¿/santiago marine.jpg? that string is the username.. And that username has spaces xD... With other username like mine, there are no spaces... ----------------------------------- Mighty Gorgon Mon 12 Oct, 2009 10:14 Re: Problems Generating Some Thumbnails ----------------------------------- When you have to use strings in URL you have to use the [b]urlencode[/b] method. [codeblock]urlencode($myurl)[/codeblock] Quotes should not be ever used. If you urlencode your urls, thumbnails should work fine. Have a try. ----------------------------------- Danielc Mon 12 Oct, 2009 16:13 Re: Problems Generating Some Thumbnails ----------------------------------- Now, my manually generated thumbnails work fine.. Anyway should i "encode" the urls? ----------------------------------- Mighty Gorgon Wed 21 Oct, 2009 20:07 Re: Problems Generating Some Thumbnails ----------------------------------- Yes, because some stupid browsers (try to guess which is one of them! :lol: ) sometimes doesn't recognize URL correctly if they are not encoded. ----------------------------------- Danielc Thu 22 Oct, 2009 01:06 Re: Problems Generating Some Thumbnails ----------------------------------- Ok, i will do that.. Thanks again, MG! ----------------------------------- Danielc Sat 24 Oct, 2009 03:35 Re: Problems Generating Some Thumbnails ----------------------------------- Sorry.. A little question.. Could you help me in where to add urlencode method?? ----------------------------------- Mighty Gorgon Mon 26 Oct, 2009 17:30 Re: Problems Generating Some Thumbnails ----------------------------------- Do you have a script generating those urls or are you typing them manually? ----------------------------------- Danielc Mon 26 Oct, 2009 23:11 Re: Problems Generating Some Thumbnails ----------------------------------- I use .htaccess to "redirect" the link to the php with the needed args.. For example: [b]http://www.rankings.miiconsola.com/Danielc.jpg[/b] is replaced with [b]http://www.rankings.miiconsola.com/ranking.php?usuario=Danielc[/b] To generate the thumbnails, i extracted some of the needed code to obtain the filename, and copy it manually to the thumbnails path.. Do you need the source code?? Thanks! ----------------------------------- Mighty Gorgon Tue 27 Oct, 2009 00:11 Re: Problems Generating Some Thumbnails ----------------------------------- I mean, where the image code is posted? Is posted in a topic or automatically in the profile? ----------------------------------- Danielc Tue 27 Oct, 2009 23:04 Re: Problems Generating Some Thumbnails ----------------------------------- It is designed to be in the signature.. But it is only if you want.. You just have to use img tag with the url provided.. Thanks again.. ----------------------------------- Mighty Gorgon Thu 05 Nov, 2009 22:01 Re: Problems Generating Some Thumbnails ----------------------------------- Who provides the URL? You need to make sure to replace all spaces by %20 for example... ----------------------------------- Danielc Thu 05 Nov, 2009 23:23 Re: Problems Generating Some Thumbnails ----------------------------------- I use .htaccess to generate the url's... The url's are written by the user.. [code linenumbers=false]sql_query($sql))) { if($user_info = $db->sql_fetchrow($result)) { imagecopy($rank_image,$base_img,0,0,0,0,imagesx($base_img),imagesy($base_img)); if ($user_info['user_allowavatar'] != 0) { if ($user_info['user_avatar'] != "") { $ruta_avatar = IP_ROOT_PATH . "images/avatars/" . $user_info['user_avatar']; } else { $ruta_avatar = IP_ROOT_PATH . "images/ranking_noavatar.png"; } } else { $ruta_avatar = IP_ROOT_PATH . "images/ranking_noavatar.png"; } $ganadas = $user_info['ranking_ganadas']; $perdidas = $user_info['ranking_perdidas']; $partidas = $ganadas + $perdidas; $puntos = $user_info['ranking_puntos']; $ranking = ($ganadas + $perdidas) == 0 ? 0 :$puntos / ($partidas); $file_part = explode('.', strtolower($ruta_avatar)); $pic_filetype = $file_part[count($file_part) - 1]; switch ($pic_filetype){ case 'jpg': case 'jpeg': $avatar = imagecreatefromjpeg($ruta_avatar); break; case 'gif': $avatar = imagecreatefromgif($ruta_avatar); break; case 'png': $avatar = imagecreatefrompng($ruta_avatar); break; default: $avatar = imagecreatefromjpeg($ruta_avatar); } $av_x = imagesx($avatar); $av_y = imagesy($avatar); if ($av_x > $avatar_size || $av_y > $avatar_size) { if ($av_x > $av_y) { imagecopyresampled($rank_image,$avatar,$avatar_pos_x,$avatar_pos_y,0 ,0,$avatar_size,$avatar_size * ($av_y / $av_x) ,$av_x, $av_y); } elseif ($av_y > $av_x) { imagecopyresampled($rank_image,$avatar,$avatar_pos_x,$avatar_pos_y,0 ,0,$avatar_size* ($av_x / $av_y),$avatar_size ,$av_x, $av_y); } else { imagecopyresampled($rank_image,$avatar,$avatar_pos_x,$avatar_pos_y,0 ,0,$avatar_size,$avatar_size ,$av_x, $av_y); } } else { imagecopy($rank_image,$avatar,$avatar_pos_x,$avatar_pos_y,0,0,$av_x,$av_y); } $textcolor = ImageColorAllocate($rank_image,255,255,255); imagettftext($rank_image,$n_font_size,0,$name_pos_x,$name_pos_y,$textcolor,$fuente,$username); $name_pos_y += 19; imagettftext($rank_image,$font_size,0,$name_pos_x,$name_pos_y,$textcolor,$fuente,"Partidas: $partidas"); $name_pos_y += 14; imagettftext($rank_image,$font_size,0,$name_pos_x,$name_pos_y,$textcolor,$fuente,"Ganadas: $ganadas"); $name_pos_y += 14; imagettftext($rank_image,$font_size,0,$name_pos_x,$name_pos_y,$textcolor,$fuente,"Perdidas: $perdidas"); imagettftext($rank_image,$font_size,0,$points_pos_x,$points_pos_y,$textcolor,$fuente,"Puntos: $puntos"); $points_pos_y += 4; imagecopy($rank_image,$star,$points_pos_x,$points_pos_y,0 ,0,imagesx($star), imagesy($star) ); $points_pos_y += 18; $points_pos_x += 6 + imagesx($star); imagettftext($rank_image,11,0,$points_pos_x,$points_pos_y,$textcolor,$fuente,$ranking); if ($jpg == 0) { $pic_id = "www.rankings.miiconsola.com/$username.png"; $pic_thumbnail_prefix = 'mid_' . md5($pic_id); $pic_thumbnail = $pic_thumbnail_prefix . '_' . $username . '.png'; $pic_thumbnail_fullpath = POSTED_IMAGES_THUMBS_PATH . $pic_thumbnail; //if(!file_exists($pic_thumbnail_fullpath)) { imagepng($rank_image, $pic_thumbnail_fullpath,9, PNG_ALL_FILTERS); @chmod($pic_thumbnail_fullpath, 0777); //} header('Content-type: image/png'); imagepng($rank_image, NULL,9, PNG_ALL_FILTERS); } else { //message_die(GENERAL_ERROR,"jpg = 1. Comprobando.. jpg = $jpg", ''); $pic_id = "www.rankings.miiconsola.com/$username.jpg"; $pic_thumbnail_prefix = 'mid_' . md5($pic_id); $pic_thumbnail = $pic_thumbnail_prefix . '_' . $username . '.jpg'; $pic_thumbnail_fullpath = POSTED_IMAGES_THUMBS_PATH . $pic_thumbnail; imagejpeg($rank_image,$pic_thumbnail_fullpath, 75); @chmod($pic_thumbnail_fullpath, 0777); header('Content-type: image/jpeg'); imagejpeg($rank_image, NULL, 75); } imagedestroy($rank_image); } else { message_die(GENERAL_ERROR,"Usuario no encontrado.", ''); } } else { message_die(GENERAL_ERROR,"No se pudo obtener la información para el usuario", ''); } } else { message_die(GENERAL_ERROR,"Usuario no especificado", ''); } ?>[/code] That is the code... So, i must do what you say in the .htaccess or in the php file?? I was thinking on double rewrite the url via htaccess, but i don't think that is the best method.. Could you help me? ----------------------------------- Mighty Gorgon Sun 05 Dec, 2010 12:50 Re: Problems Generating Some Thumbnails ----------------------------------- Did you solve this or is the issue still open? ----------------------------------- Danielc Sun 05 Dec, 2010 18:19 Re: Problems Generating Some Thumbnails ----------------------------------- I solve it generating the thumbnails manually and rewriting the urls. Thanks for your help!