B4A Library Android Support ExifInterface

DonManfred

Expert
Licensed User
This is a wrap for the Android Support ExifInterface announced here

ExifInterface4a
Author:
DonManfred (wrapper)
Version: 1.3
ExifInterface
Fields:

  • exifAttributesAPI9 As java.lang.String[]
  • exifAttributesAPI11 As java.lang.String[]
  • exifOrientationConstants As int[]
  • exifAttributesAPI23 As java.lang.String[]
  • exifAttributesAPI24 As java.lang.String[]
Methods:
  • hasThumbnail As boolean
  • getAltitude (defaultValue As double) As double
  • IsInitialized As boolean
  • isThumbnailCompressed As boolean
  • Initialize (ba As anywheresoftware.b4a.BA, EventName As java.lang.String, filePath As java.lang.String) As void
  • setAttribute (tag As java.lang.String, value As java.lang.String) As void
  • getAttribute (attribute As java.lang.String) As java.lang.String
  • getAttributeInt (attribute As java.lang.String, defaultValue As int) As int
  • GetAllAttributes As anywheresoftware.b4a.objects.collections.Map
    Will return the exifdata as read in initialize as a Map
  • saveAttributes As void
  • getAttributeDouble (attribute As java.lang.String, defaultValue As double) As double
  • getLatLong (defaultValue As float[]) As boolean
  • GetAllAttributes2 As anywheresoftware.b4a.objects.collections.Map
    Will return the most-up-to-date exifdata as a Map
Properties:
  • ThumbnailRange As long[] [read only]
  • ThumbnailBytes As byte[] [read only]
  • GpsDateTime As long [read only]
  • ThumbnailBitmap As android.graphics.Bitmap [read only]
  • Thumbnail As byte[] [read only]
  • DateTime As long [read only]

Basic usage

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim exif As ExifInterface
    Private rp As RuntimePermissions
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private Button1 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    If File.Exists(rp.GetSafeDirDefaultExternal("pics"), "hd_roccaabisso.jpg") = False Then
        File.Copy(File.DirAssets,"hd_roccaabisso.jpg",rp.GetSafeDirDefaultExternal("pics"), "hd_roccaabisso.jpg")
    End If
    Dim filePath As String
    filePath = File.Combine(rp.GetSafeDirDefaultExternal("pics"), "hd_roccaabisso.jpg")
    exif.Initialize("",filePath)
    Dim m As Map = exif.GetAllAttributes
    'Log(m)
    'Log(m.Get("UserComment"))
    Dim usercomment As String = m.Get("UserComment")
    Log("Length of UserComment read: "&usercomment.Length)
    exif.setAttribute("UserComment",usercomment) ' overwrite the Usercomment with new content... here no change as it writes back the UserComment which was in the image...
    exif.saveAttributes ' Save all changes back to the image.
End Sub
 

Attachments

Peter Simpson

Expert
Licensed User
This is excellent @DonManfred, thank you...

DateTime - 2013:08:01 20:49:15
ExposureTime - 0.00625
Flash - 16
FocalLength - 1600/100
GPSAltitude - null
GPSAltitudeRef - null
GPSDateStamp - null
GPSLatitude - null
GPSLatitudeRef - null
GPSLongitude - null
GPSLongitudeRef - null
GPSProcessingMethod - null
GPSTimeStamp - null
ImageLength - 2592
ImageWidth - 4608
Make - FUJIFILM
Model - FinePix HS50EXR
Orientation - 1
WhiteBalance - 1
Artist - null
BitsPerSample - null
BrightnessValue - 913/100
CFAPattern - null
ColorSpace - 1
ComponentsConfiguration - ???
CompressedBitsPerPixel - 32/10
Compression - 6
Contrast - null
Copyright -
CustomRendered - 0
DateTimeDigitized - 2013:08:01 20:49:15
DateTimeOriginal - 2013:08:01 20:49:15
DeviceSettingDescription - null
DigitalZoomRatio - null
ExifVersion - 0230
ExposureBiasValue - 0/100
ExposureIndex - null
ExposureMode - 1
ExposureProgram - 1
FileSource - ?
FlashpixVersion - 0100
FlashEnergy - null
FocalLengthIn35mmFilm - null
FocalPlaneResolutionUnit - 3
FocalPlaneXResolution - 7166/1
FocalPlaneYResolution - 7166/1
FNumber - 11.0
GainControl - null
GPSAreaInformation - null
GPSDestBearing - null
GPSDestBearingRef - null
GPSDestDistance - null
GPSDestDistanceRef - null
GPSDestLatitude - null
GPSDestLatitudeRef - null
GPSDestLongitude - null
GPSDestLongitudeRef - null
GPSDifferential - null
GPSDOP - null
GPSImgDirection - null
GPSImgDirectionRef - null
GPSMapDatum - null
GPSMeasureMode - null
GPSSatellites - null
GPSSpeed - null
GPSSpeedRef - null
GPSStatus - null
GPSTrack - null
GPSTrackRef - null
GPSVersionID - null
ImageDescription - null
ImageUniqueID - null
InteroperabilityIndex - R98
ISOSpeedRatings - 100
JPEGInterchangeFormat - 1796
JPEGInterchangeFormatLength - 6430
LightSource - 1
MakerNote - FUJIFILM?
MaxApertureValue - 300/100
MeteringMode - 5
OECF - null
PhotometricInterpretation - null
PixelXDimension - 4608
PixelYDimension - 2592
PlanarConfiguration - null
PrimaryChromaticities - null
ReferenceBlackWhite - null
RelatedSoundFile - null
ResolutionUnit - 2
RowsPerStrip - null
SamplesPerPixel - null
Saturation - null
SceneCaptureType - 0
SceneType - ?
SensingMethod - 2
Sharpness - 2
ShutterSpeedValue - 730/100
Software - Digital Camera FinePix HS50EXR Ver1.01
SpatialFrequencyResponse - null
SpectralSensitivity - null
StripByteCounts - null
StripOffsets - null
SubjectArea - null
SubjectDistance - null
SubjectDistanceRange - 0
SubjectLocation - null
ApertureValue - 690/100
SubSecTimeDigitized - null
SubSecTimeOriginal - null
ThumbnailImageLength - null
ThumbnailImageWidth - null
TransferFunction - null
UserComment - null
WhitePoint - null
XResolution - 72/1
YCbCrCoefficients - null
YCbCrPositioning - 2
YCbCrSubSampling - null
YResolution - 72/1
** Activity (main) Resume **
 

Peter Simpson

Expert
Licensed User
Hey, leave my camera alone @DonManfred :) I've owned a every camera in the HS series of camera, HS10, HS20, HS30 and HS50 which is great for moon shots.

Anyway this library is absolute fabulous, cheers Manfred...

Photo from my phone.
Length of UserComment read: 4
DateTime - 2016:12:26 19:06:38
ExposureTime - 0.023094
Flash - 9
FocalLength - 4670/1000
GPSAltitude - null
GPSAltitudeRef - null
GPSDateStamp - null
GPSLatitude - null
GPSLatitudeRef - null
GPSLongitude - null
GPSLongitudeRef - null
GPSProcessingMethod - null
GPSTimeStamp - null
ImageLength - 3024
ImageWidth - 4032
Make - Huawei
Model - Nexus 6P
Orientation - 1
WhiteBalance - 0
Artist - null
BitsPerSample - null
BrightnessValue - -22/100
CFAPattern - null
ColorSpace - 1
ComponentsConfiguration - ???
CompressedBitsPerPixel - null
Compression - 6
Contrast - 0
Copyright - null
CustomRendered - 1
DateTimeDigitized - 2016:12:26 19:06:38
DateTimeOriginal - 2016:12:26 19:06:38
DeviceSettingDescription - null
DigitalZoomRatio - null
ExifVersion - 0220
ExposureBiasValue - 0/6
ExposureIndex - null
ExposureMode - 0
FileSource - null
FlashpixVersion - 0100
FocalLengthIn35mmFilm - null
FocalPlaneResolutionUnit - null
FocalPlaneYResolution - null
GainControl - null
GPSDestBearing - null
GPSDestBearingRef - null
GPSDestDistance - null
GPSDestLatitude - null
GPSDestLatitudeRef - null
GPSDestLongitudeRef - null
GPSDOP - null
GPSImgDirectionRef - M
GPSMapDatum - null
GPSSatellites - null
GPSSpeedRef - null
GPSTrack - null
GPSVersionID - null
ImageUniqueID - null
InteroperabilityIndex - R98
JPEGInterchangeFormat - 5872
LightSource - 0
MaxApertureValue - 200/100
MeteringMode - 2
PhotometricInterpretation - null
PixelXDimension - 4032
PlanarConfiguration - null
ReferenceBlackWhite - null
ResolutionUnit - 2
RowsPerStrip - null
Saturation - 0
SceneType - ?
Sharpness - 0
ShutterSpeedValue - 544/100
SpatialFrequencyResponse - null
StripByteCounts - null
StripOffsets - null
SubjectDistance - 1.05
SubjectLocation - null
SubSecTimeDigitized - 495776
SubSecTimeOriginal - 495776
ThumbnailImageWidth - 252
TransferFunction - null
WhitePoint - null
** Activity (main) Resume **
 
Top