Re: SV: [PHP] Problems with images..
On Mon, Nov 3, 2008 at 2:46 PM, Ashley Sheridan [EMAIL PROTECTED]wrote: On Mon, 2008-11-03 at 15:56 +0100, Anders Norrbring wrote: Anders Norrbring wrote: I've been staring myself blind, so now I don't get anywhere, please do advice.. I have a web page printed with PHP, in a table I need to display images that are stored in a SQL DB. Getting the images into variables isn't an issue at all, but how do I output it? This is what I want to accomplish: trtdCurrent image:/tdtd - THE IMAGE HERE - /td/tr Starting to pull my hair.. Anders. img src=fetchimg?id=n/ fetchimg.php: header('Content-Type: image/jpeg'); $img=fetch from db; print $img; True Per, but I would prefer one single file in this case.. Anders. You can have the image script as part of the same PHP file, by checking to see if it is being called for an image rather than a normal page, but it just makes things more convoluted. Also, the base64 method will not work in IE. I had a similar problem at work that could only be solved by using a separate script to output the image. It can't be streamed inline in a consistent manner. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I too prefer to have the image called from a separate page. img src='getimage.php?id=12345'/ That way if the images are of differeing types (tiff/png/jpg/etc) I can locate all the handling code in the getimage.php file and its becomes the one place to handle this kind of stuff -- Bastien Cat, the other other white meat
[PHP] Problems with images..
I've been staring myself blind, so now I don't get anywhere, please do advice.. I have a web page printed with PHP, in a table I need to display images that are stored in a SQL DB. Getting the images into variables isn't an issue at all, but how do I output it? This is what I want to accomplish: trtdCurrent image:/tdtd - THE IMAGE HERE - /td/tr Starting to pull my hair.. Anders. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problems with images..
-Original Message- From: Anders Norrbring [mailto:[EMAIL PROTECTED] Sent: Monday, November 03, 2008 7:44 AM To: php-general@lists.php.net Subject: [PHP] Problems with images.. I've been staring myself blind, so now I don't get anywhere, please do advice.. I have a web page printed with PHP, in a table I need to display images that are stored in a SQL DB. Getting the images into variables isn't an issue at all, but how do I output it? This is what I want to accomplish: trtdCurrent image:/tdtd - THE IMAGE HERE - /td/tr Starting to pull my hair.. trtdCurrent image:/tdtdimg src=?= $variableName ? //td/tr If you don't have the proper INI setting to allow for the short-hand ?= ?, you can replace it with: ?php echo $variableName; ? If this made you pull your hair out, then perhaps you should go back and get a fundamental understanding of HTML and PHP basics before trying to combine the two. Just sayin'. HTH, Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
SV: [PHP] Problems with images..
I've been staring myself blind, so now I don't get anywhere, please do advice.. I have a web page printed with PHP, in a table I need to display images that are stored in a SQL DB. Getting the images into variables isn't an issue at all, but how do I output it? This is what I want to accomplish: trtdCurrent image:/tdtd - THE IMAGE HERE - /td/tr Starting to pull my hair.. trtdCurrent image:/tdtdimg src=?= $variableName ? //td/tr If you don't have the proper INI setting to allow for the short-hand ?= ?, you can replace it with: ?php echo $variableName; ? If this made you pull your hair out, then perhaps you should go back and get a fundamental understanding of HTML and PHP basics before trying to combine the two. Just sayin'. Thank you for your wonderful sarcasm Todd. But the solution you suggest just won't work, and as a programmer, you should be just about knowledgeable enough to know that. However, I got a tip about something that WILL work, so I prefer to listen to that person instead. She said; td ?php ob_start(); echo $info['image']; $data = base64_encode(ob_get_contents()); ob_end_clean(); echo img src=\data:image/jpeg;base64,$data\; ? /td -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
SV: [PHP] Problems with images..
Anders Norrbring wrote: I've been staring myself blind, so now I don't get anywhere, please do advice.. I have a web page printed with PHP, in a table I need to display images that are stored in a SQL DB. Getting the images into variables isn't an issue at all, but how do I output it? This is what I want to accomplish: trtdCurrent image:/tdtd - THE IMAGE HERE - /td/tr Starting to pull my hair.. Anders. img src=fetchimg?id=n/ fetchimg.php: header('Content-Type: image/jpeg'); $img=fetch from db; print $img; True Per, but I would prefer one single file in this case.. Anders. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems with images..
Anders Norrbring wrote: I've been staring myself blind, so now I don't get anywhere, please do advice.. I have a web page printed with PHP, in a table I need to display images that are stored in a SQL DB. Getting the images into variables isn't an issue at all, but how do I output it? This is what I want to accomplish: trtdCurrent image:/tdtd - THE IMAGE HERE - /td/tr Starting to pull my hair.. Anders. img src=fetchimg?id=n/ fetchimg.php: header('Content-Type: image/jpeg'); $img=fetch from db; print $img; /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problems with images..
-Original Message- From: Anders Norrbring [mailto:[EMAIL PROTECTED] Sent: Monday, November 03, 2008 8:56 AM To: Boyd, Todd M. Cc: php-general@lists.php.net Subject: SV: [PHP] Problems with images.. I've been staring myself blind, so now I don't get anywhere, please do advice.. I have a web page printed with PHP, in a table I need to display images that are stored in a SQL DB. Getting the images into variables isn't an issue at all, but how do I output it? This is what I want to accomplish: trtdCurrent image:/tdtd - THE IMAGE HERE - /td/tr Starting to pull my hair.. trtdCurrent image:/tdtdimg src=?= $variableName ? //td/tr If you don't have the proper INI setting to allow for the short-hand ?= ?, you can replace it with: ?php echo $variableName; ? If this made you pull your hair out, then perhaps you should go back and get a fundamental understanding of HTML and PHP basics before trying to combine the two. Just sayin'. Thank you for your wonderful sarcasm Todd. But the solution you suggest just won't work, and as a programmer, you should be just about knowledgeable enough to know that. However, I got a tip about something that WILL work, so I prefer to listen to that person instead. She said; td ?php ob_start(); echo $info['image']; $data = base64_encode(ob_get_contents()); ob_end_clean(); echo img src=\data:image/jpeg;base64,$data\; ? /td I was, in fact, NOT being sarcastic. Perhaps if you had been more specific about images in variables (it looks like you're using BLOBs, I had guessed you were using filenames and storing the images on disk... which is another argument altogether), my answer (or sarcasm, in your eyes) would have been more direct to your question. As for my solution not working--for BLOBs, no. Of course not. My analogy of your question, however, is a bit like this: Q: How do I turn on this light switch? A: You flip it to the 'on' position. ... Q: No, I mean how do I route power from the solar panels on my roof to produce a current that will be affected by this lightswitch? I don't see the reason for Base64 encoding anything, but I'm glad (also not sarcastic) that you got the answer to your question that you were looking for. I also hope that you learned to be more specific when you're requesting assistance, and not throwing someone's suggestions back in their face when they were just trying to lend you a hand with what they understood your question to be. Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: SV: [PHP] Problems with images..
On Mon, 2008-11-03 at 15:56 +0100, Anders Norrbring wrote: Anders Norrbring wrote: I've been staring myself blind, so now I don't get anywhere, please do advice.. I have a web page printed with PHP, in a table I need to display images that are stored in a SQL DB. Getting the images into variables isn't an issue at all, but how do I output it? This is what I want to accomplish: trtdCurrent image:/tdtd - THE IMAGE HERE - /td/tr Starting to pull my hair.. Anders. img src=fetchimg?id=n/ fetchimg.php: header('Content-Type: image/jpeg'); $img=fetch from db; print $img; True Per, but I would prefer one single file in this case.. Anders. You can have the image script as part of the same PHP file, by checking to see if it is being called for an image rather than a normal page, but it just makes things more convoluted. Also, the base64 method will not work in IE. I had a similar problem at work that could only be solved by using a separate script to output the image. It can't be streamed inline in a consistent manner. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems creating images
On Wed, April 5, 2006 2:42 pm, Age Bosma wrote: *confirm_image.php:* Your browser and webserver see confirm_image.php in the URL. Header(Content-type: image/jpeg); REAL browsers like Mozilla and Firefox etc trust this. Microsoft, however, in its infinite wisdom, ignores standards-compliant Content-type: headers and guesses at the content type from the URL. Thus, odds are really good that some versions of IE on some versions of MS will decide that your image must be a JPEG. The only generalized solution I know of is to make sure you IMG tag *ends* with .jpg imt src=confirm_image.php/ie_sucks.jpg / IE (some versions) will see the .jpg and know it's a JPEG, and ignore the Content-type: ImageString ($image, 5, 12, 2, $code, $text_color); ImageJPEG($image, '', 75); ImageDestroy($image); Most people get a nice image but some people get only, what appears to be, garbage: ÿØÿàJFIFÿþ;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), XXX The stuff above XXX... That doesn't look like valid JPEG starting characters in my experience... PERHAPS they're fine, or part of some new standard, but every JPEG I ever saw started with the stuff above It's possible that your code_bg.jpg has EXIF data and/or is a progressive JPEG, and that GD preserves that info, and that some browsers are incapable of displaying such a JPEG. For the complete output have a look here: http://www.samuel-area.de/phpbook/confirm_image.php The crucial thing here is that SOMETHING is forcing some kind of output and the Content-type: is being set to text/html on that server for that URL: -bash-2.05b$ telnet www.samuel-area.de 80 Trying 82.149.248.196... Connected to www.samuel-area.de. Escape character is '^]'. GET /phpbook/confirm_image.php HTTP/1.0 Host: www.samuel-area.de HTTP/1.1 200 OK Date: Fri, 14 Apr 2006 00:02:11 GMT Server: Apache/2.0.53 (Fedora) X-Powered-By: PHP/4.3.11 Content-Length: 1519 Connection: close Content-Type: text/html; charset=iso-8859-1 JFIF;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 75 C $.' ,#(7),01444'9=82.342C Do you know what is going wrong here? So, most definitely, in this case, something is configured incorrectly on that server to over-ride your header() call and it's spewing out the JPEG as if it were HTML. My first guess would be some kind of security setting/module which is trying to be smart about .php which is forcing the final output Content-type: to be text/html, even though PHP is perfectly capable of generating ANY kind of content. Since it's an Apache server, if the trick above (end URL in .jpg) does not work, you could try this: #1 mv confirm_image.php confirm_image.jpg Now the URL will look JUST like a .jpg to everybody. #2 Edit a file .htaccess in that same directory as confirm_image.php and add this to it: Files confirm_image.jpg ForceType application/x-httpd-php /Files Now Apache knows that this particular .jpg file should be passed through PHP to generate output. #3 Change your IMG tag to point to: confirm_image.jpg If that STILL doesn't fix it, you're going to have to get the administrator of that server to figure out why their server insists on spewing out Content-type: text/html for a dynamic JPEG. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] Problems creating images
On Thu, April 6, 2006 5:24 pm, Tom Rogers wrote: put error_reporting( E_ALL); at the top of the script and see if any error messages show up. The fact that the mime type is text seems to indicate some output has gone to the client before your header call. That could be any white space outside of ?php..? and could be in an include file or prepend file as well. Actually, if it's an auto_prepend file, you'll need to change the reporting level in .htaccess, or it's too late by the time your script starts executing, no? php_value error_reporting 2047 Note: I don't think E_ALL is kosher in .htaccess, so I used the value of E_ALL my PHP reports from: php -r 'echo E_ALL, \n;' I think E_ALL changed value at some point, though... Maybe you can have your client put up a ?php echo E_ALL;? page. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems creating images
Tom Rogers wrote: Make sure you don't have any blank lines before the ?php There isn't. I've got the suspicion it's got to do with the UTF-8 character encoding because of the characters '', I've seen this before with HTML pages. Because of this I asked the person who's having the problems to upload and test three different files versions of the php file: - ANSI - UTF-8 - ANSI UTF-8 without BOM None had any effect what so ever. What else can I try? Philip Hallstrom pointed out that the returning header is set to 'Content-Type: text/html; charset=iso-8859-1' instead of 'Content-type: image/jpeg'. What could be the cause of this? Yours, Age -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] Problems creating images
Hi, Friday, April 7, 2006, 6:20:41 AM, you wrote: AB Tom Rogers wrote: AB There isn't. I've got the suspicion it's got to do with the UTF-8 AB character encoding because of the characters '', I've seen this AB before with HTML pages. Because of this I asked the person who's having AB the problems to upload and test three different files versions of the AB php file: AB - ANSI AB - UTF-8 AB - ANSI UTF-8 without BOM AB None had any effect what so ever. What else can I try? AB Philip Hallstrom pointed out that the returning header is set to AB 'Content-Type: text/html; charset=iso-8859-1' instead of 'Content-type: AB image/jpeg'. What could be the cause of this? AB Yours, AB Age put error_reporting( E_ALL); at the top of the script and see if any error messages show up. The fact that the mime type is text seems to indicate some output has gone to the client before your header call. That could be any white space outside of ?php..? and could be in an include file or prepend file as well. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems creating images
I added image confirmation to a guestbook and even though it works greate for most people, some people have problem and I can't seem to figure out why this happens. Note that I'm not talking about the same guestbook on one server but the guestbook is on people's own hosting server. The php code to create the image can't be simpler: *confirm_image.php:* $datekey = date(F j); $rcode = hexdec(md5($_SERVER[HTTP_USER_AGENT] . $cfg_sitekey . $random_num . $datekey)); $code = substr($rcode, 2, 6); $image = ImageCreateFromJPEG(images/code_bg.jpg); $text_color = ImageColorAllocate($image, 80, 80, 80); Header(Content-type: image/jpeg); ImageString ($image, 5, 12, 2, $code, $text_color); ImageJPEG($image, '', 75); ImageDestroy($image); Most people get a nice image but some people get only, what appears to be, garbage: JFIF;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 75 C $.' ,#(7),01444'9=82.342C 2!!22 ...snip... For the complete output have a look here: http://www.samuel-area.de/phpbook/confirm_image.php Do you know what is going wrong here? Not entirely, but when I go to that URL and check the headers (Live HTTP header extension in firefox) I get this: HTTP/1.x 200 OK Date: Wed, 05 Apr 2006 20:02:02 GMT Server: Apache/2.0.53 (Fedora) X-Powered-By: PHP/4.3.11 Content-Length: 1501 Connection: close Content-Type: text/html; charset=iso-8859-1 Notice that last one... I see you set it up above, but it isn't sticking -philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems creating images
Hi, I added image confirmation to a guestbook and even though it works greate for most people, some people have problem and I can't seem to figure out why this happens. Note that I'm not talking about the same guestbook on one server but the guestbook is on people's own hosting server. The php code to create the image can't be simpler: *confirm_image.php:* $datekey = date(F j); $rcode = hexdec(md5($_SERVER[HTTP_USER_AGENT] . $cfg_sitekey . $random_num . $datekey)); $code = substr($rcode, 2, 6); $image = ImageCreateFromJPEG(images/code_bg.jpg); $text_color = ImageColorAllocate($image, 80, 80, 80); Header(Content-type: image/jpeg); ImageString ($image, 5, 12, 2, $code, $text_color); ImageJPEG($image, '', 75); ImageDestroy($image); Most people get a nice image but some people get only, what appears to be, garbage: ÿØÿàJFIFÿþ;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 75 ÿÛC $.' ,#(7),01444'9=82.342ÿÛC 2!!22ÿÀ ...snip... For the complete output have a look here: http://www.samuel-area.de/phpbook/confirm_image.php Do you know what is going wrong here? Yours, Age -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems creating images
Hi, Thursday, April 6, 2006, 5:42:05 AM, you wrote: AB Hi, AB I added image confirmation to a guestbook and even though it works AB greate for most people, some people have problem and I can't seem to AB figure out why this happens. Note that I'm not talking about the same AB guestbook on one server but the guestbook is on people's own hosting server. AB The php code to create the image can't be simpler: AB *confirm_image.php:* AB $datekey = date(F j); AB $rcode = hexdec(md5($_SERVER[HTTP_USER_AGENT] . $cfg_sitekey . AB $random_num . $datekey)); AB $code = substr($rcode, 2, 6); AB $image = ImageCreateFromJPEG(images/code_bg.jpg); AB $text_color = ImageColorAllocate($image, 80, 80, 80); AB Header(Content-type: image/jpeg); AB ImageString ($image, 5, 12, 2, $code, $text_color); AB ImageJPEG($image, '', 75); AB ImageDestroy($image); AB Most people get a nice image but some people get only, what appears to AB be, garbage: AB ÿØÿàJFIFÿþ;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), AB quality = 75 ÿÛC $.' AB ,#(7),01444'9=82.342ÿÛC AB 2!!22ÿÀ AB ...snip... AB For the complete output have a look here: AB http://www.samuel-area.de/phpbook/confirm_image.php AB Do you know what is going wrong here? AB Yours, AB Age Make sure you don't have any blank lines before the ?php -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problems displaying images with PHP-GD
Ian Johnson wrote: I am trying to use GD to create and manipulate images but the statement: header (Content-type: image/jpg); generates the error message: The image http://localhost/gdtst2.php; cannot be displayed, because it contains errors. Wild Guess: You have a blank line in your file before the first ?php or after the last ? -- So even though it looks like a kosher JPEG, it's not. Use View Source in your browser on the JPEG data to see what's there. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems displaying images with PHP-GD
Hello I am trying to use GD to create and manipulate images but the statement: header (Content-type: image/jpg); generates the error message: The image http://localhost/gdtst2.php; cannot be displayed, because it contains errors. There is no error message in the ../httpd/error_log file. I am using PHP 5.0.3 with GD 2.0.28. The report from phpinfo() indicates gd present and enabled. Other nongraphics content-types do not gererate errors. Code used was First Program from tutorial at http://www.phpfreaks.com/tutorials/105/1.php. Similar code from php manual generates the same error. I suspect the solution is simple but I'm just not seeing it! Help Ian Johnson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problems with images
I make som images on-the-fly with php. Scandinavian spesial characters comes out with a square instead. I use a font that I have placed on root. What can I do to fix this? egil berntsen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php