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

Posted on 2004-11-02
Last Modified: 2008-01-09

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 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.
Question by:sapan_desai
    LVL 8

    Accepted Solution

    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
    LVL 23

    Expert Comment

    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.

    LVL 2

    Expert Comment

    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.

    Author Comment


    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.


    LVL 8

    Expert Comment

    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.*,*" %>

     File filems = new File("./pathtojpg.jpg");
    long timems = filems.lastModified();
    Date datems = new Date(timems);

    Hope this helps

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Suggested Solutions

    Title # Comments Views Activity
    why to use string 10 53
    Problem to adjust sheet 1 78
    FizzBuzz challenge 9 64
    array11 challenge 16 40
    Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
    Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now