473,396 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Speed up Camera Photo Time Stamp

I'm writing a program for renaming my picture files, and I want to use
the picture time stamp as a prefix to the file names. I can get the
time stamp, but it is extraordinarily slow! I have about 250 pictures
in the directory. In debug mode, I can populate the names in a
listview in less than two seconds. If I add a column with the time
stamp as a string, the listview takes about 70 seconds to populate in
debug mode. I haven't made and test a release mode yet.

Does anybody know a faster way to get the time stamp information?

'---------- Extract the picture date from the picture ----------
' Return an empty string if the file does not exist or no date tag
' Returns date string in YYYY:MM:DD HH:MM:SS
Private Function GetRawDate(ByVal FileName As String) As String
Dim l_RawDate As String = ""
If File.Exists(FileName) Then
Try
Dim img As Image = Image.FromFile(FileName)
Dim i As PropertyItem
For Each i In img.PropertyItems
If (i.Id = &H9003 Or i.Id = &H9004) And i.Type = 2
Then
l_RawDate =
System.Text.Encoding.Default.GetString(i.Value, 0, i.Value.Length - 1)
Exit For
End If
Next
Catch ex As Exception
End Try
End If
Return l_RawDate
End Function

'---------- Get the date only in YY-MM-DD format ----------
' FullDate is in YYYY:MM:DD HH:MM:SS format
' Returns date string in YY-MM-DD format
Private Function GetPictureYYMMDD(ByVal FullDate As String) As
String
Dim l_YYMMDD As String = ""
If FullDate.Length >= 10 Then
l_YYMMDD = FullDate.Substring(2, 2) + "-" + _
FullDate.Substring(5, 2) + "-" + _
FullDate.Substring(8, 2)
End If
Return l_YYMMDD
End Function

'---------- Populate the listview ----------
Private Sub Populate()
Dim l_Directory As String = txtDirectory.Text

lvw.BeginUpdate()
lvw.Clear()
lblSelected.Text = "0 Selected"
If My.Computer.FileSystem.DirectoryExists(l_Directory ) = False
Then
MsgBox("Directory name is invalid.",
MsgBoxStyle.Exclamation)
Else
Dim l_File As String
Dim l_Item As ListViewItem
Dim l_FileInfo As System.IO.FileInfo
Dim s As String = ""

lvw.Columns.Add("File Name")
lvw.Columns.Add("Picture Taken")
lvw.Columns.Add("Last Edited Date")
lvw.Columns.Add("Preview")
Try
For Each l_File In
My.Computer.FileSystem.GetFiles(l_Directory)
l_Item = New ListViewItem(l_File)
l_FileInfo = New System.IO.FileInfo(l_File)
s = GetRawDate(l_File)
s = GetPictureYYMMDD(s)
l_Item.SubItems.Add(s)
lvw.Items.Add(l_Item)
Next
Catch ex As Exception
End Try
End If
lvw.EndUpdate()
End Sub

Aug 1 '07 #1
2 1839
Shane wrote:
I'm writing a program for renaming my picture files, and I want to use
the picture time stamp as a prefix to the file names. I can get the
time stamp, but it is extraordinarily slow! I have about 250 pictures
in the directory. In debug mode, I can populate the names in a
listview in less than two seconds. If I add a column with the time
stamp as a string, the listview takes about 70 seconds to populate in
debug mode. I haven't made and test a release mode yet.

Does anybody know a faster way to get the time stamp information?
You are reading the entire image, which includes reading the entire file
and decompressing the image into a bitmap.

You can read the metadata directly from the file instead. That of course
means that you have to read up on the format of the file to find out how
to get to the interresting parts.

Alternatively you might find someone else who has already written code
for that.

--
Göran Andersson
_____
http://www.guffa.com
Aug 1 '07 #2
Ok, yeah, that's pretty obvious that the image variable was the
slowing down area.

I could use a background task to update the dates in my list, but I'd
rather not.

Does anybody have faster code?

Shane

Aug 2 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Yang Li Ke | last post by:
Hi guys, Im about to build a script which will log visitor time spent on my website. I got a few ideas about this, maybe checking visitors ip and storing that info in db with time in and then...
6
by: Newbie | last post by:
I am doing some robotics projects but my main area of interest is trying out several algorithms for the processing of the stream of data coming from the video. I am wondering what type of camera...
1
by: Pola | last post by:
I am working with IIS. I am using ISAPI Extension dll, that runs on the web server. I am working on the appl that have to receive images(jpeg from video camera) in the real time. the client...
7
by: Don | last post by:
Hi all, With regards to the following, how do I append the datetimestamp to the filenames in the form? The files are processed using the PHP script that follows below. Thanks in advance,...
1
by: Bill | last post by:
Does anyone know of a Python program that will re-name digital photo files in a date-time format based on the date stamp of the file?
8
by: Alexander Fischer | last post by:
Hello, I am writing a gallery script and use imagecreatefromjpeg and fpassthru to output images without any change to them (i.e., no thumbnail creation etc. - just deliver the image via the php...
4
by: SilentThunderer | last post by:
Hey folks, Let me start out by letting you know what I'm working with. I'm building an application in VB 2005 that is basically a userform that employees can use to "Clock in". The form...
1
by: cumupkid | last post by:
II am trying to create a form that will allow me to upload photos to a folder in the site root directory and add the information to the mysql db at the same time. I have created two forms, one...
5
by: brijesh1234 | last post by:
Dear Sir/Madam With a request I would like to submit that I am developing an application in PHP where I want to use the following features as 1. On a click button of a PHP page, a live web...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.