B4A Library JpegUtils library gives access to Exif data

Discussion in 'Additional libraries, classes and official updates' started by agraham, Sep 21, 2011.

  1. agraham

    agraham Expert Licensed User

    This library contains an ExifData object that allows you to read and write the EXIF data in a Jpeg file. It is a very thin wrapper over the Android ExifInterface class.
     

    Attached Files:

    JCO, Jones Hone, Mashiane and 3 others like this.
  2. bluedude

    bluedude Well-Known Member Licensed User

    That sounds awesome, could mean I can write GPS stuff to the images taken with the camera.
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Johan Hormaza likes this.
  4. mkvidyashankar

    mkvidyashankar Active Member Licensed User

    I am trying to save some description to jpg exif data. What is the tag to save description ?
     
  5. praetor100

    praetor100 New Member

    Hi agraham,

    I'm also would like to save descriptions into jpg exif data. Please could you add this meta tag in your library?

    Thank you and best regards
    praetor
     
  6. agraham

    agraham Expert Licensed User

  7. praetor100

    praetor100 New Member

    OK, I understand. Is there a way to write IPTC tags? Some apps can this do (i.e. MoPhotos)

    kind regards
    praetor
     
  8. agraham

    agraham Expert Licensed User

    You will have to roll your own in code or find a Java library to wrap.
     
  9. wheretheidivides

    wheretheidivides Active Member Licensed User

    I did find this link which goes over exif data. Such as the numbers for orientation and such. Listed below are some numbers returned by this library in case you wondered what they were. These are the tags like: x = exif.getAttribute(exif.TAG_FLASH). X is a string that will hold the returned info. the rest that are currently supported by the library have no variable info. this really needs to be with docs so people can find easily.

    EXIF Tags
    http://developer.android.com/reference/android/media/ExifInterface.html#TAG_GPS_ALTITUDE
    ==============================
    orientation:
    0 = unassigned
    1 = Horizontal (normal)
    2 = Mirror horizontal
    3 = Rotate 180
    4 = Mirror vertical
    5 = Mirror horizontal and rotate 270 CW
    6 = Rotate 90 CW
    7 = Mirror horizontal and rotate 90 CW
    8 = Rotate 270 CW
    ======================
    white balance
    0 = Auto
    1 = Manual
    =========================
    GPSLatitudeRef
    'N' = North
    'S' = South
    ======================
    GPSLongitudeRef
    'E' = East
    'W' = West
    =======================
    GPSAltitudeRef
    0 = Above Sea Level
    1 = Below Sea Level
    =====================
    GPSProcessingMethod
    (values of "GPS", "CELLID", "WLAN" or "MANUAL" by the EXIF spec.)
    =====================
    GPSDateStamp
    (when writing, time is stripped off if present, after adjusting date/time to UTC if time includes a timezone. Format is YYYY:mm:dd)
    ===========================
    ApertureValue
    (displayed as an F number, but stored as an APEX value)
    ================================
    GPSTimeStamp
    (when writing, date is stripped off if present, and time is adjusted to UTC if it includes a timezone)
    ============================
    "GPSAltitude"
    The altitude (in meters) based on the reference in TAG_GPS_ALTITUDE_REF. Type is rational.
    1 Meter = 3.28083989501312 Feet
    1 mile = 5280 feet
    ==============================
    "GPSLatitude"
    String. Format is "num1/denom1,num2/denom2,num3/denom3".
    ===========================
    "GPSLongitude"
    String. Format is "num1/denom1,num2/denom2,num3/denom3".

    ==========================
    flash:
    Indicates the status of flash when the image was shot.

    Bit 0 indicates the flash firing status, bits 1 and 2 indicate the flash return status, bits 3 and 4 indicate the flash mode, bit 5 indicates whether the flash function is present, and bit 6 indicates "red eye" mode.

    Values for bit 0 indicating whether the flash fired.
    0 = Flash did not fire
    1 = Flash fired

    Values for bits 1 and 2 indicating the status of returned light.
    00 = No strobe return detection function
    01 = reserved
    10 = Strobe return light not detected
    11 = Strobe return light detected

    Values for bits 3 and 4 indicating the camera's flash mode.
    00 = unknown
    01 = Compulsory flash firing
    10 = Compulsory flash suppression
    11 = Auto mode

    Values for bit 5 indicating the presence of a flash function.
    0 = Flash function present
    1 = No flash function

    Values for bit 6 indicating the camera's red-eye mode.
    0 = No red-eye reduction mode or unknown
    1 = Red-eye reduction supported

    Not all combinations make sense though. The specification defines these combined values:

    hex 0000 = Flash did not fire
    hex 0001 = Flash fired
    hex 0005 = Strobe return light not detected
    hex 0007 = Strobe return light detected
    hex 0009 = Flash fired, compulsory flash mode
    hex 000D = Flash fired, compulsory flash mode, return light not detected
    hex 000F = Flash fired, compulsory flash mode, return light detected
    hex 0010 = Flash did not fire, compulsory flash mode
    hex 0018 = Flash did not fire, auto mode
    hex 0019 = Flash fired, auto mode
    hex 001D = Flash fired, auto mode, return light not detected
    hex 001F = Flash fired, auto mode, return light detected
    hex 0020 = No flash function
    hex 0041 = Flash fired, red-eye reduction mode
    hex 0045 = Flash fired, red-eye reduction mode, return light not detected
    hex 0047 = Flash fired, red-eye reduction mode, return light detected
    hex 0049 = Flash fired, compulsory flash mode, red-eye reduction mode
    hex 004D = Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected
    hex 004F = Flash fired, compulsory flash mode, red-eye reduction mode, return light detected
    hex 0059 = Flash fired, auto mode, red-eye reduction mode
    hex 005D = Flash fired, auto mode, return light not detected, red-eye reduction mode
    hex 005F = Flash fired, auto mode, return light detected, red-eye reduction mode

    =========================
     
    Last edited: Feb 2, 2013
    shashkiranr likes this.
  10. gadgetmonster

    gadgetmonster Active Member Licensed User

    Exif data always blank

    Hi All

    I'm having issues getting to the exif data using this library and could really do with some help please.

    I use the contentchooser to allow the user to pic a photo from the camera. Once selected I end up in

    Code:
    imageChooser_Result (Success As Boolean, Dir As String, FileName As String)
    Which gives me the directory and filename. As a simple test I then do:

    Code:
    exif.Initialize(Dir, FileName)
    Dim temp As String
    temp = exif.getAttribute(exif.TAG_DATETIME)
    But temp is always blank. I don't get any exceptions either.

    Any ideas?
     
  11. gadgetmonster

    gadgetmonster Active Member Licensed User

    Just to add, I have copied the images from my device onto my PC to verify that exif data is present and it is. My camera images b y default are stored on my SD card so I have also copied them onto the device itself and still no joy.

    When returning from the content chooser, Dir = ContentDir and the Filename = content://media/external/images/media/3425 which is odd as this is not the actual name of the jpg when viewing in windows. Could this be the problem and if so how to get the correct filename.

    Thanks in advance :)
     
    Last edited: Mar 27, 2013
  12. agraham

    agraham Expert Licensed User

    Run the JpegUtils demo and check that the date is shown in the message box that shows when you tap the picture. A blank date may be a sign that the filename or directory is not valid. For some reason the Android ExifInterface object, which this library wraps, does not throw an Exception when initialised with an non-existent file. The initialiser for ExifInterface takes a full path (Android is not very consistent with filenames and paths) which is done like this.
    Code:
    exif = new ExifInterface(dir + "/" + filename);
    Log your directory and filename and see what they look like.
     
  13. agraham

    agraham Expert Licensed User

    From the help for ContentChooser
    Looks like you need to do some string manipulation.
     
  14. swissmade

    swissmade Active Member Licensed User

    Copy Image to new resized Image with EXIF data

    Hi all,

    I wondering, if it is possible, to copy the old EXIF data to the new resized Image.
    I have try this but then you must copy Tag for Tag.

    Is there an other way to do this.

    To explain this better
    I take a Picture with my Camera save as "1.jpg"
    Then I resize the Image to about 800x600
    Save this Image as "2.jpg"
    In "1.jpg" I still have the EXIF data and "2.jpg" has no EXIF data.

    Many thanks for any help.:sign0163:
     
  15. agraham

    agraham Expert Licensed User

    Not with this library or within the Android API. You would need to wrap some code like metadata-extractor in a library.
     
  16. swissmade

    swissmade Active Member Licensed User

    Thanks for the answer,

    I think I have to search for a different way.

    Cheers
     
  17. corvo

    corvo Member Licensed User

    Help whit lat and lon

    Hi, i have some problem to extract gps coordinates from a jpeg, whit the command

    my string contain on a letter: "N", and if i use

    my string is made by strange value, like 150/569.456/1452N

    how i can take the coords whit your library?

    :sign0104::sign0104:
     
  18. Erel

    Erel Administrator Staff Member Licensed User

    Can you post the exact string?
     
  19. corvo

    corvo Member Licensed User

    Thank you erel, this is the string

    and i got also problem if i try to save the exif data in a string, i need a example :(:sign0104:
     
  20. agraham

    agraham Expert Licensed User

    Here is the format of the GPS Exif tags.

    TIFF Tag Reference, GPS Tags

    By following the links you will see Latitude and Longitude are expressed as three rational numbers.

     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice