BBC BASIC for Windows
« Reading dates from JPG files »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 9:54pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Reading dates from JPG files  (Read 846 times)
simong42
New Member
Image


member is offline

Avatar




PM


Posts: 14
xx Reading dates from JPG files
« Thread started on: Jan 15th, 2014, 08:17am »

Is there anyone out there who's learned how to read date information from JPEG files, using BBC BASIC?
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Reading dates from JPG files
« Reply #1 on: Jan 15th, 2014, 09:12am »

on Jan 15th, 2014, 08:17am, simong42 wrote:
Is there anyone out there who's learned how to read date information from JPEG files, using BBC BASIC?

I personally haven't, but I don't think the EXIF data is particularly difficult to parse. BBC BASIC's PTR# pseudo-variable makes following the links straightforward.

There's a description of the EXIF file format here:

http://www.media.mit.edu/pia/Research/deepview/exif.html

Richard.
User IP Logged

JGHarston
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 52
xx Re: Reading dates from JPG files
« Reply #2 on: Jan 19th, 2014, 3:40pm »

Here's an initial framework to scan through the Exif header:

REM > ReadExif
:
in%=OPENIN("")
PROCexif_list(in%)
END
:
DEFPROCexif_list(in%)
LOCAL marker%,endian%,size%,tag%,format%,offset%,exif%,lp%,ptr%
:
REPEAT
marker%=FNrd16(in%,1)
IF marker%<>&FFD8 THEN size%=FNrd16(in%,1) ELSE size%=2
IF marker%<>&FFE1 THEN PTR#in%=PTR#in%-2+size%
UNTIL EOF#in% OR marker%=&FFE1
IF EOF#in% THEN ENDPROC :REM No TIFF marker found
IF FNrd32(in%,0)<>&66697845 THEN ENDPROC :REM No 'Exif' marker
IF FNrd16(in%,0)<>0 THEN ENDPROC :REM No zero word
exif%=PTR#in%-1 :REM Base of exif area
endian%=FNrd16(in%,0) :REM Get endian flag
IF endian%=&4949 THEN endian%=0 ELSE IF endian%=&4D4D THEN endian%=1 ELSE ENDPROC
:
size%=FNrd32(in%,endian%) :REM Size of exif catalogue
num%=FNrd16(in%,endian%) :REM Skip two bytes
num%=FNrd16(in%,endian%) :REM Number of exif entries
:
item%=0
REPEAT
tag% =FNrd16(in%,endian%)
format%=FNrd16(in%,endian%)
size% =FNrd32(in%,endian%)
offset%=FNrd32(in%,endian%)
ptr%=PTR#in%
IF size%<4 THEN PTR#in%=PTR#in%-4 ELSE PTR#in%=exif%+offset%
:
CASE tag% OF
WHEN &0132:
PRINT "Date: ";:FOR lp%=1 TO size%:VDU BGET#in%:NEXT lp%: PRINT
WHEN &010F:
PRINT "Make: ";:FOR lp%=1 TO size%:VDU BGET#in%:NEXT lp%: PRINT
ENDCASE
:
PTR#in%=ptr%:item%=item%+1
UNTIL EOF#in% OR item%=num%
ENDPROC
:
DEFFNrd16(i%,e%)
IF e%=0:=BGET#i%+256*BGET#i% ELSE =256*BGET#i%+BGET#i%
:
DEFFNrd32(i%,e%)
LOCAL m%: DIM m% LOCAL 3
IF e%=0 :m%?0=BGET#i%:m%?1=BGET#i%:m%?2=BGET#i%:m%?3=BGET#i%
IF e%<>0:m%?3=BGET#i%:m%?2=BGET#i%:m%?1=BGET#i%:m%?0=BGET#i%
=!m%
User IP Logged

simong42
New Member
Image


member is offline

Avatar




PM


Posts: 14
xx Re: Reading dates from JPG files
« Reply #3 on: Feb 11th, 2014, 11:49am »

Excellent : thanks very much indeed!
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls