Jiokah Posted December 22, 2008 Share Posted December 22, 2008 Hey guys, I seem to be missing something here, when I output an image to the browser it comes out as broken and I have no idea why. The last project I did was a business card maker that outputted tons of (working) images, and I'm doing everything the same here. I use output buffering, and wiping the buffer right before header() and imagejpeg() doesn't work. I think it may have something to do with my encoding, though I've played around with that too. The only difference between this project and the last is that I'm now using UTF-8 encoding, with the bom. I have define('_ISO','charset=UTF-8'); set as well as UTF-8 with BOM option set in my editer. Could that be affecting this? Any ideas? ??? Link to comment https://forums.phpfreaks.com/topic/137965-image-not-outputting/ Share on other sites More sharing options...
Jiokah Posted December 24, 2008 Author Share Posted December 24, 2008 Hey guys, I'm still getting this problem, if anyone has any clues I would greatly appreciate them! I don't think it's encoding anymore as I've played around a lot with that and it still does not work. It shouldn't be an error finding it's way into the output either because I use my own error system, not PHPs. This one really has me stumped! Works fine when I save it to a file instead of output. When comparing the two files in notepad, they are identical, except that the broken one has about 20 blank lines at the top. Not only do I not have any spaces in my script, but I've cleared the buffer directly before the header and imagejpeg functions. Link to comment https://forums.phpfreaks.com/topic/137965-image-not-outputting/#findComment-723387 Share on other sites More sharing options...
thebadbad Posted December 24, 2008 Share Posted December 24, 2008 I would suspect the BOM to be the culprit here (I always use UTF-8 without it, since it only causes trouble). But show us some code! Link to comment https://forums.phpfreaks.com/topic/137965-image-not-outputting/#findComment-723394 Share on other sites More sharing options...
Jiokah Posted December 26, 2008 Author Share Posted December 26, 2008 Hah! It was the bom, wow thanks dude. I didn't think it was as I had this same problem with ascii encoding. Well who knew, stupid bom. What's the point of it anyways? Link to comment https://forums.phpfreaks.com/topic/137965-image-not-outputting/#findComment-724017 Share on other sites More sharing options...
thebadbad Posted December 27, 2008 Share Posted December 27, 2008 From Wikipedia: While UTF-8 does not have byte order issues' date=' a BOM encoded in UTF-8 may nonetheless be encountered, though the Unicode standard does not recommend using it[1']. It only identifies a file as UTF-8 and does not state anything about byte order.[2] Many Windows programs (including Windows Notepad) add BOM's to UTF-8 files. However in Unix-like systems (which make heavy use of text files for file formats as well as for inter-process communication) this practice is not recommended, as it will interfere with correct processing of important codes such as the hash-bang at the start of an interpreted script. It may also interfere with source for programming languages that don't recognise it. For example, gcc reports stray characters at the beginning of a source file, and in PHP, if output buffering is disabled, it has the subtle effect of causing the page to start being sent to the browser, preventing custom headers from being specified by the PHP script. The UTF-8 representation of the BOM is the byte sequence EF BB BF, which appears as the ISO-8859-1 characters  in most text editors and web browsers not prepared to handle UTF-8. Link to comment https://forums.phpfreaks.com/topic/137965-image-not-outputting/#findComment-724195 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.