beginner question exifr returns errors

P

pm

Hello everyone,

I've a piece of code that looks for 'jpeg' files and reads their exif
and then puts them into appropriate folders. Some times 'bad formated'
jpeg-files gives me a runtime error on the exifr call.

How can I avoid this ? In the case of a bad formated jpeg file I would
like to be able to read the next one, without interrupting the program

My code is :
---------------------------------------------------------

if (File.stat(f).ftype == "file") and (f.include? ".jpg" or
f.include? ".JPG") then
j = EXIFR::JPEG.new(f)

if j.exif? then

my_date = j.date_time_original.to_s.split
my_month = my_date[1]
 
H

Hassan Schroeder

I've a piece of code that looks for 'jpeg' files and reads their exif and
then puts them into appropriate folders. Some times 'bad formated'
jpeg-files gives me a runtime error on the exifr call.

How can I avoid this ? In the case of a bad formated jpeg file I would like
to be able to read the next one, without interrupting the program

You can rescue the exception and log it, ignore it, whatever.

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,175
Messages
2,570,946
Members
47,498
Latest member
yelene6679

Latest Threads

Top