|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
SQL image/blob display problems
I'm new to php (and this forum) and have spent the past week trying to figure out how to display an SQL image field. I've finally gotten an image to render but it's only partially displaying the image (the rest of the image is grey - like it ran out of ink).
I'm accessing a third party database and they've not included an image's size in the database. The images that've been stored are all different sizes ranging from about 250px to about 700 px. The smaller images render correctly about halfway then turn to grey. The larger images are correct for only about 10 px/lines and then turn to grey. So my questions/issues are as follows: How do I get the entire image to render correctly? and How can I standardize the size of the image rendered - to a width of say, 250px? Here's the code that I'm using: PHP Code:
The display line is as follows: <img src='display.php?id=".$id."'> Let me know if there's any other information you need to consider this problem. I appreciate any insight or help provided. Last edited by jlisham : August 25th, 2009 at 09:37 AM. |
|
#2
|
|||
|
|||
|
i found this makes things really easy, it's a function i created some time ago.
PHP Code:
then just call it like so echo DynamicPicReturn("path for image", $width).'<BR>'; What this does is call the picture (try putting it in a loop to check your database) and you can specify the second parameter Width to force them all to resize to the same width (but different heights)
__________________
29 years of creative writing 13 years of HTML 10 years of Photoshop 6 years of PHP/MySQL And I never knew Photoshop could do HTML until 2004! You learn something new every day. |
|
#3
|
|||
|
|||
|
I appreciate your response. Thank you!
To my novice eye it looks like this code's not pulling images from a database but a location/folder and resizing them. The resizing part is great and I think I can see how to make it work once the images have been converted from binary to jpg, but that's really the first problem I have - the conversion to jpg. Thoughts, anyone? |
|
#4
|
|||
|
|||
|
you shouldn't have to do any sort of conversion from the binary data to the image. check out the user comments on the manual page for mssql_query(). there are a lot of posts and some sample code that should help you.
|
|
#5
|
|||
|
|||
|
Quote:
well yes the files are stored in a folder but their path is in a database. Normally i save the filename to the database and then apend in the function call the path. But you could just apend the file path from your database. Id advise agaisnt storying images in the database itself as that adds unnessicary over head, referencing a folder is cleaner, IMHO |
|
#6
|
|||
|
|||
|
Thank you for your response/time.
Sorry, I misspoke the question somewhat. I meant conversion only in the sense that a binary data field would be displayed as a jpg. I'm using the same code as the msssql_query() page you referenced and it does render the image - just not all of it. I'm missing something... and that something seems to be limiting the amount of 'image' that can be seen. Is this an ini issue? or some other config issue? Timeout? I'm usually able to find something to point me in the right direction but haven't located a heck-of-a lot of information on this (I've been looking!). That must mean this is either really easy or a really bad idea. Either way I'm stuck with only half an image. This appears to be the important bit of code needed: PHP Code:
and I'm using that. |
|
#7
|
|||
|
|||
|
Quote:
Unfortunately the storage method wasn't my choice - I'm pulling data from a third party database... |
|
#8
|
|||
|
|||
|
I honestly don't know. It sounds like the data in the table is being truncated like from either the blob field set to small of a size or possibly the connection is timing out and stopping after retrieving the result half way or maybe an error like a notice error/warning is causing a problem and the error is being spit out half way through the image so it stops at that point. I would check the error thing, just remove the header() call and you will get the image as if you opened it in notepad. then look through all that randomness to see if there is an error in the middle somewhere. if that doesn't work, maybe check the size of the image you get back from the result and compare that to the same image on the server. a simple count of characters in the source of the image should match or at least if you notice a big difference it could help narrow it down.
|
|
#9
|
|||
|
|||
|
adding to lamma's comments, can you do a url direct access to the image. ie can you point your browser manually at www.site.com/images/myimg.jpg
if so then we know the image is good and just retrieving it from the database is the problem |
|
#10
|
|||
|
|||
|
(BTW - I'm just way out of my depth!)
I've removed the header info and the images render as before. I did take a look at the image properties and they all seem to be either 4028k or 8194k (this latter is of an image that is almost all grey) and this seems like it should be an important clue. I looked at the ini file and can't find a corresponding limit - like max size is 4M or somesuch. I'm trying to connect with the software developer who owns the database and am hoping that it'll be all downhill from there. Is it usual to store blob images without including file type and size? It seems like I should be specifying the file size in the rendering code somewhere but as far as I can tell, it's not being collected. one additional piece of info - the images are available through the application and also by report generation (MS Word) and are rendering correctly in those formats. Last edited by jlisham : September 1st, 2009 at 11:15 AM. |
|
#11
|
|||
|
|||
|
Quote:
The images don't exist in that format - they're stored as type IMAGE in a SQL database. or am I missing something? |
|
#12
|
|||
|
|||
|
Quote:
what i'm saying is save the database content locally in say word, (if you can access it via say php my admin) and try and deplay it in hard code. Don't extract and convert, do a hard copy convert just to make sure the file itself isn't bad. |
|
#13
|
|||
|
|||
|
turns out it was an ini file setting after all - just made the following adjustments
PHP Code:
and problem solved. Thanks for all your efforts! |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > SQL image/blob display problems |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|