[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to Extract Creation Time / Date of .jpg Image from Linux WebServer ?

Posted on 2004-11-02
5
Medium Priority
?
777 Views
Last Modified: 2008-01-09
Hi,

This is what I've been trying to do:
_______________________________________________________________________________
I've been stuck trying to do this for some days now. It doesn't seem like its very difficult, but for some reason I haven't been able to figure it out.

I'm working on a project where I need a .jpg image is sent from a Canon S400 camera to a custom application which processes it (for cropping etc.), which is then ftp'd to a LINUX Web Server (the image is copied to another .jpg file), and is then displayed on the webpage.

Now, the problem is that, presently, the time being displayed under the image is the time from the local host machine...so it changes from machine to machine. I want the time the image was taken from the camera, i.e., the time the picture was taken, which I believe is available in the image header file.

I would appreciate if someone could help me with this. I'm not sure if there's an in-built Javascript function to do this, but just to re-iterate, what needs to be done is to extract the date / time the image was created from the header file, and display it on the webpage.
_______________________________________________________________________________

I did get some replies to this E-mail but I don't think this can be done using Javascript, on the client side.

However, I do believe that this can be done by extracting the creation date and time of the image from the file system structure (that contains directory information for each file stored on the hard disk). Since the .jpg image will be stored in the file system, I need to find the operating system call that will return the creation date and time from the file system structure. By the way, just to reiterate, its a LINUX Web Server.

It would be great if someone could reply to this asap with the system call for doing this, and the code in Java (or some other script / language), with which the time / date could be displayed on the webpage.

Thanks a million.
0
Comment
Question by:sapan_desai
5 Comments
 
LVL 8

Accepted Solution

by:
edkim80 earned 375 total points
ID: 12478342
the linux file system stores A-C-M attributes of a file.
Access time - last time the file was accessed
Change time - last time some metadata was changed i.e. permissions
Modification time- last time the actual file was changed.

There unfortunately is no native stat in the linux filesystem which stores the creation time of the file.  Most of the time either the change or modification may be the creation time, but that is not gaurenteed.
All information can be access via the 'stat' command in redhat linux. (-lu, -l and -lc ) on other systems

As for the date in an jpg header, i am almost postive that jpgs do no store any date information in their header.  I created created 2 jps at 2 different times, and did a diff ( bit by bit comparision) which resulted in no difference.

hope this helps
0
 
LVL 23

Expert Comment

by:brettmjohnson
ID: 12478428
If you can extract the image timestamp from the jpg file, you can then
use the 'touch' command to modify the timestamp of the file.

0
 
LVL 2

Expert Comment

by:danielwpc
ID: 12479634
I don't know much about Linux, but I have a IXUS400 with the window software which can put the photos in oder by the date. I think you can do whatever you want if you have the photos in different "date" folders.
0
 

Author Comment

by:sapan_desai
ID: 12661224
Hi,

I haven't been able to figure this out yet. Can someone please help me write a Linux Script, which I can use with JSP, to extract the File Modified, Access, or Change Date and Time for the .jpg file and display it on the webpage. I need the date and time for the image when the camera application last sent the image over to the web server.

It would be really helpful if someone has a good understanding of JSP and can help me write the entire code to do the above.

Thanks,

SAPAN
0
 
LVL 8

Expert Comment

by:edkim80
ID: 12666177
Hey sapan,

I don't have access to a jsp server but, here's what I wrote which might help you out.

<%@ page import="java.util.*, java.text.*, java.io.*" %>

<html>
<head></head>
<body>
<%
 File filems = new File("./pathtojpg.jpg");
long timems = filems.lastModified();
Date datems = new Date(timems);
System.out.println(DateFormat.getTimeInstance().format(datems));
%>
</body>
</html>

Hope this helps
Ed
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Introduction to Processes
Screencast - Getting to Know the Pipeline

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question