Re: [PHP] problems with several JPEGs in GD2
I've had similar problems to that. I usually either open the image with notepad, or some Hex Editor, and see what the bits are in the file header (eg BM for Bitmap, Gif89a for GIFs, JFIF for JPEGs...) -- AdamT Justify my text? I'm sorry, but it has no excuse. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with several JPEGs in GD2
i just opened 4 jpg files...dunno about where the header is...coz i didn't find anything common at the begining of the files (so i doesn't seem to have a header at the head). i found (only) one jpg which had JFIF as the 7th to 10th bytes. i did notice that the _last 2 bytes_ are FF D9 in *all* 5 jpg's. that should be a good way to check depending on how the jpeg's in question differ from the real thing. fopen image; fseek ( $handle, -2 , SEEK_END); $last_2_bytes = fread ($handle, 2 [bytes]); if ($last_2_bytes == 0xffd9), perhaps an ok jpg. have u done anything to the images? are they photos, scanned, gaphics (from photoshop/gimp)? On Tue, 1 Mar 2005 09:44:08 +, AdamT [EMAIL PROTECTED] wrote: I've had similar problems to that. I usually either open the image with notepad, or some Hex Editor, and see what the bits are in the file header (eg BM for Bitmap, Gif89a for GIFs, JFIF for JPEGs...) -- ]# Anirudh Dutt ...pilot of the storm who leaves no trace like thoughts inside a dream -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with several JPEGs in GD2
On Tue, 1 Mar 2005 16:06:56 +0530, anirudh dutt [EMAIL PROTECTED] wrote: i just opened 4 jpg files...dunno about where the header is...coz i didn't find anything common at the begining of the files (so i doesn't seem to have a header at the head). Okay - so 'header' was a bad choice of word. 'Marker' would have been better: http://www.funducode.com/freec/Fileformats/format3/format3b.htm -- AdamT Justify my text? I'm sorry, but it has no excuse. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with several JPEGs in GD2
On Tue, 1 Mar 2005 10:40:59 +, AdamT [EMAIL PROTECTED] wrote: On Tue, 1 Mar 2005 16:06:56 +0530, anirudh dutt [EMAIL PROTECTED] wrote: i just opened 4 jpg files...dunno about where the header is...coz i didn't find anything common at the begining of the files (so i doesn't seem to have a header at the head). Okay - so 'header' was a bad choice of word. 'Marker' would have been better: just meant i couldn't find it there. http://www.funducode.com/freec/Fileformats/format3/format3b.htm very nice info on that page. thanks. quoting... Header : ·It occupies two bytes. ·0xff, 0xd8 (SOI : Start Of Image ) (these two identify a JPEG/JFIF file) so u were right about the header bit. and as murphy would have it...i start seeing all the JFIF stuff in the images. turns out my hex editor scrolls to the end so i wasn't actually looking at the headers :P got the footer right ;-) -- ]# Anirudh Dutt ...pilot of the storm who leaves no trace like thoughts inside a dream -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with several JPEGs in GD2
AdamT wrote: I usually either open the image with notepad, or some Hex Editor, and see what the bits are in the file header (eg BM for Bitmap, Gif89a for GIFs, JFIF for JPEGs...) It actually is called a header in most formal graphic specifications I've read... Checking the actual bytes of an image, especially the first few, is always a Good Idea. But having the first few bytes correct doesn't guarantee validity, of course. Even the fact that one or more other software packages can work with an image doesn't guarantee validity, really. Though if a LOT of them work with it, it's probably valid. -- 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 with several JPEGs in GD2
Hi, PHP 4.3.10, GD2 I've noticed that there is a group of JPEG files that cannot be operated with GD2 functions. For example, if you try to imagecreatefromjpeg(my.jpg) it replies: Warning: imagecreatefromjpeg(): 'my.jpg' is not a valid JPEG file in C:\Program Files\Apache Group\Apache2\htdocs\test.php on line 20 (this is not a scripting error, it works with lots of other jpegs) Meanwhile the same my.jpg file can be shown in web browser by HTML tag img src=my.jpg, can be opened in PhotoShop.. and other programs.. But GD2 thinks that it is not a valid JPEG.. Any suggestions how to deal with these types of JPEGs in GD2? Any workaround? Thanks, Mario -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with several JPEGs in GD2
Mario Lopez wrote: I've noticed that there is a group of JPEG files that cannot be operated with GD2 functions. For example, if you try to imagecreatefromjpeg(my.jpg) it replies: Warning: imagecreatefromjpeg(): 'my.jpg' is not a valid JPEG file in C:\Program Files\Apache Group\Apache2\htdocs\test.php on line 20 (this is not a scripting error, it works with lots of other jpegs) Meanwhile the same my.jpg file can be shown in web browser by HTML tag img src=my.jpg, can be opened in PhotoShop.. and other programs.. But GD2 thinks that it is not a valid JPEG.. Any suggestions how to deal with these types of JPEGs in GD2? Any workaround? I encountered this recently (except the PhotoShop part), and it turned out that: 1. The JPEG in question was *NOT* a JPEG at all. 2. The JPEG in question was *REALLY* an .art (ART) file. 3. ART files are an AOL invention in a proprietary format. 4. AOL takes an image (JPEG or GIF) Converts it to the other format (GIF or JPEG) Blindly chooses the smaller file size, Saves it as an .ART file. But sometimes simplifies life for AOL Users by pretending it's a JPEG 5. So *YOU* end up with a file that ends in .jpg but isn't a JPEG 6. And most/some non-AOL browsers happily display these ART files The Linux file command is what properly identified the file for me, I *think*... Not 100% sure on that part. Oooh, maybe IrfanView was the tool that tipped me off that I was dealing with a bogus JPEG. IrfanView Rocks! Try the GIMP too -- Almost for sure not that, as I was using a Windows box at the time, so wouldn't have had GIMP installed. (Yes, I know GIMP runs on Windows now) AFAIK, You can undo the ART packaging *only* by installing all of AOL (ugh!) and then opening up the image in their editor and doing a Save As... It only took me 10 minutes to figure out that after starting AOHell, I could *CLOSE* the window that looks like a modal dialog that pushes me to connect/signup with AOL and then I can use the Tools menu (or whatever it was) to open/edit/save the image. If you Google for ART JPEG AOL Convert you should find the same pages I did that led me down this path to success. YMMV NAIAA IANAL Somebody from the OpenSource community who wants to fix this issue by writing some quick hack utilities to easily identify and un-package ART files to non-proprietary... errr, less-proprietary, formats would probably gain a lot of reputation quickly and easily. I don't grok enough about image formats to do it myself. Of course, *YOUR* images may not be ART images, and might just be broken JPEGs. They might also be using some fancy JPEG thing that GD2 doesn't support... Interlacing? GD2 does that, though, I think... Maybe something like that. So maybe they *ARE* JPEGs, but are using a feature of JPEGs that GD2 doesn't do -- Open up a bunch of good images in PhotoShop, and bunch of bad ones and see what they have in common in terms of features like Interlacing and Gradients (?) and, err, other PhotoShop-y things of which I'm ignorant. PhotoShop: I click on the buttons a lot, and if it's pretty, I go on, and if it's not, I hit Undo I think some monkeys would be better at PhotoShop than me. :-) -- 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