Android Question JpegUtils e dati GPS

Surreal

Member
Licensed User
Longtime User
Good evening everyone, I need help

I've been going crazy for two days with the fantastic JpegUtils v1.0 library, Camera2 V1.12 and CamEx2 1.31
the problem is this writes the TAG_MAKE, the TAG_MODEL but when I have to write the TAG_GPS_LATITUDE and TAG_GPS_LONGITUDE it doesn't write anything :-(
Reading the info or properties of the image after saving from windows or Cx File Explorer I only find TAG_MAKE, TAG_MODEL but not the GPS coordinates
if I use getAttribute the data is there :-( but I need to read them from windows

the code is this:

Sub Scrivi_TAG_GPS
Try
exif.Initialize(FileDir, NomeFile)

exif.setAttribute(exif.TAG_GPS_LATITUDE, ctostring(Latitudine))
exif.setAttribute(exif.TAG_GPS_LONGITUDE, ctostring(Longitudine))
exif.setAttribute(exif.TAG_MODEL, "MODELLO TELEFONO")
exif.setAttribute(exif.TAG_MAKE, "ALTRI DATI")

exif.saveAttributes()


Dim temp_lat = exif.getAttribute(exif.TAG_GPS_LATITUDE)
Dim temp_lon = exif.getAttribute(exif.TAG_GPS_LONGITUDE)


Catch
HandleError(LastException)
End Try

End Sub

Sub ctostring(ang As Float) As String
Dim deg As Int
Dim mint As Int
Dim sec As Double
Dim minf As Float
Dim clus As String

deg = ang
minf= (ang-deg)*60
mint= (ang-deg)*60
sec =(minf-mint)*60
clus = deg & "/1," & mint & "/1," & sec &"/1"
Return(clus)
End Sub
 
Last edited:

Sagenut

Expert
Licensed User
Longtime User
This is the International section of the forum.
It's required to write in English.
Try replacing
B4X:
Return(clus)
with
Return:
Return clus
In case we wait for you even in the Italian section of the forum.
 
Upvote 0

Surreal

Member
Licensed User
Longtime User
Unfortunately nothing changes, the GPS data is not written in the photo.
I use Camera2 V1.12 and CamEx2 1.31 the other data appears instead.
Thanks and sorry again
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
I tried and it works, I can retrieve what I write in those fields.
We need some more info.
Can you export and attach your project?

*** EDIT ***
My try was with the original JPEGUTILS example, so with an already included pic.
Don't know if this could mean something.
 
Last edited:
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
I did a test even with a picture taken with CameraEX2, and it still works here.
 
Upvote 0

Surreal

Member
Licensed User
Longtime User
Yes it actually works ;-)
What happens, after acquiring the photo with CameraEX2 I apply a label on the image and save it.

B4XImageView1.Bitmap = RotateJpegIfNeeded(bmp, Data)
DateTime.DateFormat = "yyyy-MM-dd HH:mm:ss"
lblData.Text = DateTime.Date(DateTime.Now) 'Imposta il testo sulla foto. La Label è inserita nel Designer
Sleep(1000)
pnlBackground.SetVisibleAnimated(500, False)
Sleep(500)
bmp = pnlBackground.Snapshot 'Prende lo Snapshot del Panel che contiene la foto e il testo

Dim NomeFile As String = extDBUtils.Ticks2Date("yyyy-MM-dd-HH-mm-ss",DateTime.Now) & ".jpg"
Dim out As OutputStream = File.OpenOutput(VideoFileDir, NomeFile, False) 'Salva la foto con il testo
bmp.WriteToStream(out, 100, "JPEG")
out.Close

exif.Initialize(VideoFileDir, NomeFile)
exif.setAttribute(exif.TAG_GPS_LATITUDE, Latitudine)
exif.setAttribute(exif.TAG_GPS_LONGITUDE, Longitudine)

after OutputStream you can no longer assign GPS values because the file has evidently lost some info.
I hope I explained myself well.
Last question, do you think it would be possible to have an upgrade of the CameraEx2 so that it can also record in Horizontal?
Thank you for everything.
 
Upvote 0
Top