473,788 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to find out the image size stored in database?

8 New Member
Hi All..

images are stored in database(imagec ontent and image type is stored).Current ly i have displayed the image in popup window (no size limits to window). I would like to get the image size and display accordingly.
is it possible to get image size if i retireve imagecontent from databse?

Please anyone help me out.


Thanks..
Nov 14 '07 #1
9 4192
realin
254 Contributor
Hi All..

images are stored in database(imagec ontent and image type is stored).Current ly i have displayed the image in popup window (no size limits to window). I would like to get the image size and display accordingly.
is it possible to get image size if i retireve imagecontent from databse?

Please anyone help me out.


Thanks..
Correct me if i am wrong.. but you said stored image content in the database.. meaning.. what you did ? Stored the binary form of image, or you mean you stored its name in the database ?

You can get the size of an image using imagesx and imagesy function for more info goto Image functions in php

cheers !!
Nov 14 '07 #2
shailajaAdiga
8 New Member
Correct me if i am wrong.. but you said stored image content in the database.. meaning.. what you did ? Stored the binary form of image, or you mean you stored its name in the database ?

You can get the size of an image using imagesx and imagesy function for more info goto Image functions in php

cheers !!

Thanks for your reply.

I have stored image content(blob) in database not image name..
i'l look into the url

thanks once again
Nov 14 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, shailajaAdiga.

LENGTH() works on binary strings as well as text.
Nov 14 '07 #4
realin
254 Contributor
Heya, shailajaAdiga.

LENGTH() works on binary strings as well as text.

I dont know what does it show.. but when i uploaded an image of 28KB showed me 7 ... how come ? as per the manual it should show the number of bytes and if it does then also .. it showing the accurate ones..

correct me if i am wrong.. cause just now i learnt what's BLOB :p

and i suppose she wants to show the WxH and i suppose that imagesx and imagesy is the best function.. she can just fetch the values when she is about to shwo the image..

what say ?
Nov 14 '07 #5
pbmods
5,821 Recognized Expert Expert
Heya, Realin.

Ah, I see. The OP is looking for the image dimensions, not the file size. In which case you are correct; imagesx() and imagesy() would be the best options.

Incidentally, a much less memory-intensive implementation would be to determine and store these values in the database with the image data.
Nov 14 '07 #6
realin
254 Contributor
yup.. storing the image size at the time of upload is the best option.. you can further add more info like, the type of image, size,downloaded times, category, a tinyint column to show image or not to show.. etc etc..

that would be a better appraoch :)

btw, what does OP stands for .. "our programmer" :P
Nov 14 '07 #7
shailajaAdiga
8 New Member
Correct me if i am wrong.. but you said stored image content in the database.. meaning.. what you did ? Stored the binary form of image, or you mean you stored its name in the database ?

You can get the size of an image using imagesx and imagesy function for more info goto Image functions in phpcheers !!

Since i didnt store image name in databse I have tried this one..
retrive the binay form of image ,write that content into one tempfile...
then by using tempfile name findout image size(found this concept in php manual)
i could get height and width value..

still have to look into it to get it done properly..

thanks

Expand|Select|Wrap|Line Numbers
  1. //function to get image size
  2. function getimagesize_raw($data){
  3.                         $cwd = getcwd(); #get current working directory
  4.                         $tempfile = tempnam("$cwd/tmp", "temp_image_");#create tempfile and return the path/name (make sure you have created tmp directory under $cwd
  5.  
  6.                         $temphandle = fopen($tempfile, "w");#open for writing
  7.                         fwrite($temphandle, $data); #write image to tempfile
  8.                         fclose($temphandle);
  9.                         $imagesize = getimagesize($tempfile); #get image params from the tempfile
  10.                        echo $imagesize;
  11.                         unlink($tempfile); // this removes the tempfile
  12.                         return $imagesize;
  13.                    } 
  14.  
  15. if ( $image_id > 0 ) {
  16.                                $sql = "SELECT image FROM organization_logos WHERE image_id = '$image_id' ";
  17. $result = mysql_query($sql) or die(mysql_error());
  18.                             $row = mysql_fetch_assoc($result);
  19.                             extract($row);
  20.                             /*$size = getimagesize_raw($image);
  21.  
Nov 14 '07 #8
realin
254 Contributor
does storing the pic in this binary format.. degrades its quality on its reform ??
Nov 14 '07 #9
shailajaAdiga
8 New Member
does storing the pic in this binary format.. degrades its quality on its reform ??

when i display th image, quality of the picture is not that good
Nov 19 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

7
1754
by: Tom | last post by:
hello friends I want to specify a field to save icons I want to give this field a maximum of 120kb for each icon to be stored in the db. what datatype should I assign to this field and how do I specify the size ? Thanks Tom
6
2539
by: bissatch | last post by:
Hi, I have a collection of images stored in a DB. They are there for the purpose of a news system. When the user views the homepage it will diplay cropped versions of the news where the user will them click the 'read more' link to view the entire article. It will also display a thumbnail of the article image. As the image is stored at its full display size in the DB I need to be able to resize it before outputing it.
0
3254
by: P N | last post by:
Hi all, I have question about copying picture from MS-Word into the Clipboard and then copy from the Clipboard into the bitmap variable within C#. The original image size is 2288 x 1712. If I were to copy the image from Ms- Word and "Paste as New Image" in Photo Editor, I got the resolution 2288 x 1712. If I used the code below, I got the image size of 720 x 538 stored in PreviewBitmap variable. Why is the size of the picture...
5
1469
by: Neo Geshel | last post by:
I still have a problem displaying images from an access DB using asp.net. This showimage.aspx is for an admin site. I need to pull the correct image from the correct table, hence the two GET variables I need to re-size the image, while keeping the proper proportions, on the fly (before it gets to the browser). The images in the DB need to be full size for the actual web site; thumbnails are only needed in the admin site, hence the two...
35
2676
by: Stan Sainte-Rose | last post by:
Hi, What is the better way to save image into a database ? Just save the path into a field or save the image itself ? I have 20 000 images (~ 10/12 Ko per image ) to save. Stan
13
7690
by: Dino Buljubasic | last post by:
I want to get the size of a file stored in SQL Database (as image data type). Anybody knows how to do this? Any help will be greatelly appreciated
18
6524
by: Auto | last post by:
Hello, I would like to know how do display an image into a Gridview (ASP.NET 2.0) taken directly from a DataBase, NOT using an URL, like described in this article: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/GridViewEx06.asp I have NO URL, i have the binary image inside the DB, like the field "Photo" in the table "Employees" of the "NWIND.MDB" DataBase.
2
3534
by: bizt | last post by:
Hi, Is it possible to obtain the width/ height of an image when that image is dyanically created using a PHP script and passing GET attributes. For example: <img src="images/showImage.php?image_id=5" /> My images are created from images stored on the server, their paths stored on in database table and retrieved using the GET image_id and
0
831
by: ganeshvkl | last post by:
HI , i'm using VB.net 2003 with sql server 200 database . I'm storing images in database , it's working fine. but when the Database size is bigger, Now it's working very Slow, My Code is Below , the image displayed in Picture Box is Stored in Database. Dim msImage As New MemoryStream picture1.Image.Save(msImage, picture1.Image.RawFormat) Dim arrImage() As Byte = msImage.GetBuffer ' Close the stream object to release the resource. ...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10118
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.