Obtaining the height and width of the image when saving the image in the database

I save my images in my SQL Server database using ASP.NET (2.0).

(imageData โ†’ image) (imageType โ†’ varchar) (imageLength โ†’ bigint)

Thus, imageData will be โ€œBinary Dataโ€, and imageType will look like โ€œimage / gifโ€, and the image length will be โ€œ6458โ€ .......

Is it possible to get a HEIGHT and WIDTH image from my VB.NET code inside my ASP.NET? I want to make my notepad on my web form the size of the actual image stored in my database.

Relations Etienne

+3
source share
6 answers

, :

System.Drawing.Image.FromStream(yourStream).Height

, , , , , .

, . .

, , #, vb.net, , , .

IDataReader, , varbinary etc . , System.IO.Stream. MemoryStream - , , .

System.IO.MemoryStream yourStream = new System.IO.MemoryStream(dr["imgLength"] as byte[]);
System.Drawing.Image yourImage=System.Drawing.Image.FromStream(yourStream);

yourImage.Height;
yourImage.width
+9

. , select , .

, .

+2

, , system.drawing.image, , .

, .

+2

, 2 , .

0

I firmly believe that after several hundred gigabytes of images, you will find that the file system and static file HTTP servers are better than image storage databases. It also allows you to use thousands of existing free tools for working with images, transfers, hosts, etc. Your database may be busy and not easy to copy.

0
source
Dim mobj_wc As New System.Net.WebClient
Dim obj_BookOriginalImage As System.Drawing.Bitmap
Dim ImageInBytes() As Byte = mobj_wc.DownloadData(mstr_BookURL & mds_BookDetails.Tables(0).Rows(0).Item("BookImage"))

'CREATE A MEMORY STREAM USING THE BYTES
Dim ImageStream As New IO.MemoryStream(ImageInBytes)
obj_BookOriginalImage = New System.Drawing.Bitmap(ImageStream)
mint_ImageWidth = obj_BookOriginalImage.Width
0
source

Source: https://habr.com/ru/post/1705042/


All Articles