Image from database

Scott

Perch
Looks like I have a problem ;)

On my website, I retrieve images for the photography section from the MSSQL database. But, however on my local computer everything works just fine, it seems to have some problems on this server. Sometimes it shows all images, sometimes it shows only a couple of them, sometimes all images are shown...
Perhaps - if you pass by this thread - you could check it out, if you have the same problem : www.arsluminis.com/photography.

I hope you don't have these problems :) Then I've got nothing to worry about ...

Regards, and TIA !

Niels
 
Maybe I'm a bit un-familiar with html; but I thought that your "src" tag had to include the page that you are calling as well as the parameters. When you look at the image source it is coming from:

http://www.arsluminis.com/photography/collection/thumb/?pid=1

Shouldn't it be something like:

http://www.arsluminis.com/photography/collection/thumb/thumbgen.asp?pid=1 or

http://www.arsluminis.com/photography/collection/thumb/thumbgen.php?pid=1

Let me know if this was the problem. If it's not; I would like to know more about how you are calling the ASPImage object.
 
The way he does it should work as long as he uses Default.asp, index.asp or whatever the default page is set to.

Not sure what the problem is really, little info to go on.
 
Thanks for taking a look ! Posting code is quite difficult, as I work object-oriented, so I have a class Photo and a class Album... I think the problem has got something to do with the page that returns the images. Underneath you find the code for the page which returns thumbnails :

Code:
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    If Not Request.QueryString("pid") Is Nothing And IsNumeric(Request.QueryString("pid")) Then
      Dim thisSet As New Photos
      Dim thisPhoto As Photo
      Try
        thisSet.getPhoto(System.Convert.ToInt32(Request.QueryString("pid")))
        thisPhoto = thisSet.getPhotoAt(0)
      Catch ex As Exception
        Response.Redirect("../../")
      End Try
      Response.ContentType = CStr(thisPhoto.Content)
      Response.BinaryWrite(thisPhoto.Photo_Thumbnail)
      Response.End()
    Else
      Response.Redirect("../../")
    End If
  End Sub

The album always shows one picture in a set of only one : I mean that, if an album contains only one picture, both the thumbnail and the large image are being shown correctly (large images are always shown correctly). But as soon as there are 2 images in an album (or with the list of albums: as soon as there is more than 1 album and he has got to retrieve more than 1 thumbnail to give an impression of the album) everything goes wrong. That's why I think there is something set on the MSSQL server, which allows only a certain amount of connection in a specific timespan.
The weird thing is that - at home (on my localhost) - everything works fine ?( This is the kind of problem that causes sleepless nights, nightmares, ... ;(

Thanks for your help !

Regards,
Niels
 
Well, I can't see anything that would cause that in this code, but that doesn't preclude the possibility of errors in other places of course. However, if it's working correctly on your home machine I'd think something fishy was going on as well..

On a sidenote it might be better to generate the thumbnail when the album is updated (not sure if you're doing that), more friendly on the server ;)
 
SubSpace said:
On a sidenote it might be better to generate the thumbnail when the album is updated (not sure if you're doing that), more friendly on the server ;)

Do you mean it would be best to create a thumbnail on the fly when putting the image in the DB ? I already do this...

I'm reviewing the application, and will most likely simply upload the image with a GUID as filename, aswell as a thumbnail, and save a pointer in the database.

Regards,
Niels
 
I would have probably done it like that, unless you want to restrict access to images that works fine, and even if you do need to restrict them you can use this method.

There's no reason blobs in your database shouldn't work though, but these things can be annoying to debug.
 
Everything's fine now : I don't store the image in the database anymore, but create a thumb on the fly, and upload it together with the original image to the site with a unique id as filename. This ID is stored in the database, and is used as a pointer :]

Thanks to all for watching, checking, ...

Regards,
Niels
 
The only problem i seem not to be able to get rid of is the size of the images. Despite the fact i resized the large images to 720x540, their size remains high... (> 1 Mb). Does anyone know a solution for this?

Regards,
Niels
 
I thought it would reduce latency retrieving them from the database. Perhaps it does, but I could only get one from the db per page, and that's not the intention in a photo album :] Now I store them in the filesystem, each with a unique filename.

Regards,
Niels
 
Actually it makes a lot of sense to store your images in the databse as BLOB images because it doesn't cost you traffic or disk usage. It only affects you when you exceed your max database size. The only downside is that I have never gotten this to work right. Saving your images in the file system is more reliable and faster to retrieve. Unfortunately it will cost more if you are storing large images that increase your traffic and disk space. You probably have a problem with retrieval of BLOB's due to the number of members accesing the database server. Not much else to say. Hope this helps.
 
tonto said:
Actually it makes a lot of sense to store your images in the databse as BLOB images because it doesn't cost you traffic or disk usage. It only affects you when you exceed your max database size. The only downside is that I have never gotten this to work right. Saving your images in the file system is more reliable and faster to retrieve. Unfortunately it will cost more if you are storing large images that increase your traffic and disk space. You probably have a problem with retrieval of BLOB's due to the number of members accesing the database server. Not much else to say. Hope this helps.

Unfortunately, the first part of you reply is not correct. I remember reading a post (from Yash, I think) in this forum about 6 or 8 months ago that stated traffic from mssql counts against your bandwidth. The same post explained that your summary disk usage is the combination of disk space used by your site, storage space for email boxes, and disk space used for your database(s) (mssql, mysql, etc.). Therefore, you are not saving any disk space usage and you are actually using more bandwidth. Given this information and the likelyhood that retrieving your images from a database would use much more I/O and other server resources than necessary, it seems the practice should be avoided.

riley
 
I stand corrected. I actually have not had much success using BLOBS and have resorted to the file system. This method allways seems to work for me.
 
tonto said:
I stand corrected. I actually have not had much success using BLOBS and have resorted to the file system. This method allways seems to work for me.

That is probably much more efficient.

While I'm pointing out corrections to people's posts, let me correct my own post :)
Summary disk space also includes FTP traffic -- forgot about that.
Also, the information I mentioned (traffice and sdu) was in 2 different threads (not the same post). These are the treads I was talking about:
SDU:
http://support.jodohost.com/showthread.php?t=187
SQL transfers part of traffic:
http://support.jodohost.com/showthread.php?t=195

riley
 
Thanks for the help guys ! I also start thinking that the database issue which caused the problems, indeed is the maximum number of connections to the database server. Anyway, I adore the new method which I use from now on : resize and upload to a directory, seems faster, seems more reliable :)

Regards,
Niels
 
Niels:

If you are still having problems with your image size, remember to also change the dpi (resolution) of the image. If you are using your pictures for screen display only, monitors can only display 72 DPI. Any resolution biger than that will cause your pictures to be outlandishly large.

Hope that helps.

Doug
 
Well, thanks bigD : i just found out how to reduce filesize and maintain quite reasonable quality. I learnt that it is the combination of the three statements underneath which help, not just one or two :

Code:
      l.SmoothingMode = Drawing2D.SmoothingMode.HighSpeed
      l.InterpolationMode = Drawing2D.InterpolationMode.Low
      l.CompositingQuality = Drawing2D.CompositingQuality.HighSpeed

Thanks for the help !

Regards,
Niels
 
Back
Top