Opening a camera raw file

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Simon Knight
Posts: 845
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Opening a camera raw file

Post by Simon Knight » Sat Dec 14, 2019 5:27 pm

Hi,

Is there any way of displaying a raw image in a livecode stack?

best wishes

Simon K.
best wishes
Skids

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Opening a camera raw file

Post by richmond62 » Sat Dec 14, 2019 5:55 pm

Well, here's what the documentation says:

"The import command can import GIF, JPEG, PNG, BMP, XWD, XBM, XPM, or PBM, PGM, or PPM files."

Mind you, I cannot help feeling that a lot of those image formats are either extremely obscure or outdated.

Um: XWD (X Window Dump) format.

An XBM file is an X Bitmap Graphic file.

X PixMap (XPM) X Window System format.

These look like hangovers from MetaCard's UNIX days.

The PBM format is a lowest common denominator monochrome file format.

The PGM format is a lowest common denominator grayscale file format.

The PPM format is a lowest common denominator color image file format.

Simon Knight
Posts: 845
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Opening a camera raw file

Post by Simon Knight » Sat Dec 14, 2019 5:59 pm

Phew, that was a long way to say no ;-) . Thanks for confirming what I suspected and giving me a lesson in old image file formats.

best wishes

Simon K.
best wishes
Skids

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Opening a camera raw file

Post by richmond62 » Sat Dec 14, 2019 6:04 pm

that was a long way to say no
I didn't intend that, it is just when I saw all those strange suffixes I thought I'd find
out what on earth they all stood for.

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Opening a camera raw file

Post by Klaus » Sat Dec 14, 2019 10:56 pm

XWD, XBM, XPM, PBM, PGM and PPM are "leftovers" from the early UNIX only days (early 90s) of Metacard!
Maybe they keep them for nostalgic reasons... :D

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Opening a camera raw file

Post by richmond62 » Sat Dec 14, 2019 11:15 pm

I wonder if anyone at LiveCode central has heard of appendectomies? 8)

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Opening a camera raw file

Post by bogs » Sat Dec 14, 2019 11:17 pm

Why? You can use any (or all) of those formats on 'nixen boxen still, you insensitive clots :P
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Opening a camera raw file

Post by richmond62 » Sat Dec 14, 2019 11:26 pm

you insensitive clots
Ha, Ha, Ha . . .

Why, pray tell would you want any of those image formats on Linux when desktop Linux is now
quite capable of handling JPG, PNG, BMP and GIF?
-
Sledgehammer-dvd.jpg
Sledgehammer-dvd.jpg (26.48 KiB) Viewed 8528 times
-
Would you like Klaus and myself to fly over and cover you with kisses so you feel better?

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Opening a camera raw file

Post by bogs » Sat Dec 14, 2019 11:30 pm

richmond62 wrote:
Sat Dec 14, 2019 11:26 pm
Why, pray tell would you want any of those image formats on Linux when desktop Linux is now
Variety, it is the spice of life!
Image

Simon Knight
Posts: 845
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Opening a camera raw file

Post by Simon Knight » Tue Dec 17, 2019 10:19 pm

Dragging the thread back to the topic........

I would really like to be able to display a thumbnail of raw image. I have written a small app to rename and move image files from an memory card. At the moment I open an answer files dialog and select the images. This is o.k. but my renaming utility allows the name to include a reference to the event. It is likely that all the images taken at an event have the same creation date and I would like to be able to have the option of selecting all the images taken on a given date and assign them an event name all from within the application. To do this it is necessary to be able to view at least one image from the group in order to remember where I was on a given date.

I believe that most if not all camera raw files include a jpeg thumbnail and a jpeg preview. I also think that camera raw files are based on the tiff file format. So at the moment it seems that I have to read up on reading bytes from tiff files and following offsets to image file directories (see https://www.awaresystems.be/imaging/tif ... /TIFF6.pdf) and then onto the images themselves.

Its all doable but is tending towards hard work, meaning that I will probably just live with looking at the previews in the answer files dialog. So I wonder if there are any libraries out there that can lighten the load.

best wishes
Simon k.
best wishes
Skids

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Opening a camera raw file

Post by richmond62 » Wed Dec 18, 2019 9:29 am

http://lists.runrev.com/pipermail/use-l ... 55010.html

You can use a revBrowser object to look at tiffs.

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Opening a camera raw file

Post by capellan » Thu Dec 19, 2019 4:46 am

If your image have a jpg thumbnail, this could work:

Code: Select all

on mouseUp
   local temp
   answer file "Select image with EXIF thumbnail data"
   put it into temp
   open file temp for binary read
   read from file temp for 500000
   put it into temp1
   close file temp

   put numtobyte(255) & numtobyte(216) into tStart
   -- in Hexadecimal: FFD8 = SOI(Start of jpeg image)
   put numtobyte(255) & numtobyte(217) into tEnd
   -- in Hexadecimal: FFD9 = EOI(End of jpeg image)

   delete byte 1 to 2 of temp1
   -- delete JPEG SOI (Start of jpeg image)
   if byte -2 to -1 of temp1 = tEnd then delete byte -2 to -1 of temp1
   -- delete JPEG EOI(End of jpeg image)

   set the casesensitive to true


repeat 2 
-- Most Raw Image files just have 2 jpeg thumbnails

   put offset(tStart,temp1) into tThumbstart
   put offset(tEnd,temp1) into tThumbEnd

   put byte tThumbstart to (tThumbEnd + 1) of temp1 into tJPGThumb

   delete byte 1 to (tThumbEnd + 1) of temp1

   if tJPGThumb is not empty
   then
      create img
      set the text of it to tJPGThumb
   else
      answer "No JPEG Thumbnails in this image"
      exit to top   
      end if

   end repeat
end mouseUp
Check the mail list thread here:
http://lists.runrev.com/pipermail/use-l ... 10507.html

By the way, it would be very useful a function to check
if the binary data is a valid jpeg image.
Last edited by capellan on Tue Dec 24, 2019 3:01 am, edited 3 times in total.

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Opening a camera raw file

Post by capellan » Fri Dec 20, 2019 3:53 am

Hi Simon,

Which Brand is your camera?
In this website, the author make available to download
samples of Raw files from different cameras.
https://rawsamples.ch/index.php/en/

The script posted previously (now corrected)
works with these raw images formats:

Nikon NEF and NRW raw formats:
http://www.rawsamples.ch/raws/nikon/d1x ... ON_D1X.NEF

Sony ARW and SR2 raw formats:
http://www.rawsamples.ch/raws/sony/a100 ... Y_A100.ARW

Olympus ORF raw format:
http://www.rawsamples.ch/raws/olympus/R ... _E-PM1.ORF

Pentax PEF and DNG raw formats:
http://www.rawsamples.ch/raws/pentax/RAW_PENTAX_K-m.PEF

Simon Knight
Posts: 845
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Opening a camera raw file

Post by Simon Knight » Sat Feb 01, 2020 4:19 pm

Sorry I missed your last post back in December. I will have a look at your code.

Typically I'm using a Panasonic camera.
best wishes
Skids

Post Reply

Return to “Talking LiveCode”