Tvorba nahledu - kde mam chybu
5 příspěvků
Archiv diskusního fóra
Fórum je uzavřené a slouží pouze ke čtení. Některé informace mohou být zastaralé.
-
http://jaroskate.aktualne.cz/galerie.php Tady je zdrojak: <? header ("Content-type: image/jpeg"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HEAD> <TITLE> New Document </TITLE> </HEAD> <BODY> <? $resize_factor = 4; //tumbnail size is 1/4 from original files function resample ($filename) { global $resize_factor; //define the right function for the right image types if ((eregi("\.jpg$", $filename)) || (eregi("\.jpeg$", $filename))) { $image = ImageCreateFromJPEG ($filename); } else { echo "Error: $filename - unknown image type\n"; } //define size of original image $image_width = imagesx($image); $image_height = imagesy($image); //define size of the thumbnail $thumb_width = $image_width/$resize_factor; $thumb_height = $image_height/$resize_factor; //create the thumbnail $thumbnail = imagecreatetruecolor ($thumb_width, $thumb_height); imagecopyresampled ($thumbnail, $image, 0, 0, 0, 0, $thumb_width, $thumb_height, $image_width, $image_height); //display the thumbnail imagejpeg($thumbnail); //destroy the image to free up memories imagedestroy ($image); imagedestroy ($thumbnail); } resample ("http://jaroskate.aktualne.cz/img/trenink.jpg"); ?> </BODY> Namisto zmenseniny obrazku se mi tam ukazujou "prasarny". Hlavicku (header) tam mam, tak v cem je problem? dik
-
Protože výsledkem tvého skriptu je html kód, nemůžeš přece posílat hlavičku Content-type: image/jpeg. Tu používáš jen v případě, že vracíš čistě obrázek, ne obrázek zasazený do (x)html. Když generuješ html, je dobré hlavičku umístit taky jako meta tag do <head> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd"> lt;html;> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2"> <title>title</title> <link rel="stylesheet" type="text/css" href="css/styles.css" media="screen"> </head> <body> .....
-
nejakej nesmysl ma to bej obrazek nebo html stranka? toto me pripada jako hybridmezihtml a obrazekm proto ti z tho vYjde nesmysl pokud to vubec fungujue
-
ty totiz generujes jak html tak obrazek najednou - tzn. ze z toho musi vzniknout gulas na ten obrazek si vytvor jiny skript a do html kodu to vkladej pomoci <img src="obrazek.php?nejake_parametry" /> ...
-
diky, uz me to je jasny