0

I made an application that stores Item picture (jpeg) on SQL Server DB, I am using pictures shot with my camera (file size ~ 2 M). I am checking if picture.Width > 800 or picture.Height > 600, then I resize the picture to 800x600.

If I export picture from DB, the file size is about 100k, and if I open the same picture in photoshop, the image size is shown 1.37M.

Now my questions are: First, I want to know the space that this picture takes in my DB. The reason I'm resizing the picture before storing it in my DB, is that I imagine it taking a huge space in my DB.

Second, How do I resize a picture to keep it's aspect ratio?

Tanuj Wadhwa
  • 2,025
  • 9
  • 35
  • 57
user1104916
  • 103
  • 1
  • 11
  • 1
    A better approach would be to store your pictures on file system. You'll reduce database I/O overhead and benefit from file system/browser caching features. – Islam Yahiatene Nov 09 '13 at 15:36
  • 1
    that way, the computer becomes slow, the pictures could be deleted accidently by the user. – user1104916 Nov 09 '13 at 15:44

1 Answers1

1
  1. The size of the jpg file depends of the widht, height and the color dept. Check this link http://jan.ucc.nau.edu/lrm22/pixels2bytes/calculator.htm to calculate the image size.

  2. to resize the picture size and keep the aspect ratio there is a lot of libraries and framewrok to complete the task. I do not recomend you to implement one unless you have to (there is a lot of good libraries). check this post Image resizing algorithm.

  3. Its not good idea to store image in DB check Storing Images in DB - Yea or Nay?

Community
  • 1
  • 1
Juan Rada
  • 3,513
  • 1
  • 26
  • 26