Step by Step Preview Extraction from CR2.

Started by scarchord, June 05, 2012, 09:39:28 AM

Previous topic - Next topic

scarchord

Hi there,
I have a few hundred corrupt wedding images (Canon CR2) that I am desparatly trying to salvage .jpgs from.
I have ZERO experience with code. I'm looking for a super simple, step by step instruction list detailing how to extract a preview. Is there a way to do this for an entire folder of images? My images are stuck on an external Hard Drive ( they won't even be copied off of it to my desktop).

I will continue to search the forum for this and I apologize if this has been answered already.

many thanks...

Rob

PS, I am using the most recent version of Exiftool on a iMac with Lion ( I also have Snow Leopard on anther machine )


scarchord

OK, Here's what I've tried so far:

With an un-corrupt Raw file on my HD:

I Opened Terminal and "Copy/Pasted" this directly:

"exiftool -PreviewImage -b /Users/robc/Pictures/Selects/IMG_2073.CR2 > /Users/robc/Pictures/jj/IMG_2073bb.jpg"

this worked! - I see a 2MB Preview where it should be.

Then ( from the folder of corrupted Raws on my external HD ) I try:

"exiftool -PreviewImage -b /Volumes/250\ G/jennyjosh/raw/IMG_0887.CR2 > /Users/robc/Pictures/jj/IMG_0887b.jpg"

An image does show up in the destination folder - but it is zero kb and I get this error msg in Terminal:
"Warning: [minor] Error reading PreviewImage from file - /Volumes/250 G/jennyjosh/raw/IMG_0882.CR2
Robs-MacBook-Pro:~ robc$"

any suggestions??

thx again




Phil Harvey

#2
Hi Rob,

Attached is a script I have recently written to extract JPG preview images from corrupted files.  It takes one or more file and/or directory names as arguments, and creates "FILE_preview.jpg" images in the same directory as the original files if successful.

This is a Perl script that relies on ExifTool being installed.

There are no guarantees, but maybe this will help you out.

Your command line may look like this (if you "cd" to the directory containing the extract_preview script):

./extract_preview /Volumes/250\ G/jennyjosh/raw/IMG_0887.CR2

or

./extract_preview /Volumes/250\ G/jennyjosh/raw

OPTIONS:

  -r - recursively process sub-directories
  -a - extract all embedded JPEG images (not just largest preview)
  -o DIR - write output images to specified directory

Step-by-step intructions for running in Windows

- Phil

Edit: 2013-10-16 Updated attachment to current version of extract_preview script
Edit: 2017-10-31 Set default Mac library directory to /usr/local/bin/lib
Edit: 2018-05-04 Documented script options
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

scarchord

thanks you so much for replying so quickly.

not fully understanding what you mean by "(if you "cd" to the directory containing the extract_preview script)" ,

I pasted both lines of your code into Terminal and got this:

Robs-MacBook-Pro:~ robc$ ./extract_preview /Volumes/250\ G/jennyjosh/raw/IMG_0887.CR2
-bash: ./extract_preview: No such file or directory
Robs-MacBook-Pro:~ robc$

and

Robs-MacBook-Pro:~ robc$ ./extract_preview /Volumes/250\ G/jennyjosh/raw
-bash: ./extract_preview: No such file or directory
Robs-MacBook-Pro:~ robc$

does this mean my files are a lost cause - or did i do something wrong.

I assume that running the script on the whole folder should come up with at least one or two previews...


I'm also unsure where the preview file will be placed...


thx

Phil Harvey

#4
Hi Rob,

Did you extract the "extract_preview" file from the .tar.gz archive?  Assuming you did, and that it exists on your desktop, type these commands in a Terminal window:

cd ~/Desktop

./extract_preview /Volumes/250\ G/jennyjosh/raw/IMG_0887.CR2

- Phil

Hmmm.  I just tested this and it doesn't work for some Canon models, although I can probably fix it so it does.  What model is your camera?
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

scarchord

Hey again,

I did not extract the "extract preview" - I have no idea how to do that actually : )

All have is the "ExifTool-8.93.dmg" which I installed - but I don't even know where on my machine it is installed.

Could you tell me how to to do that in layman's terms?

thanks again!

Phil Harvey

Hi Rob,

I have just fixed the script to work with all Canon models, and updated the attachment in my previous post to version 1.01.  Please re-download the "extract.tar.gz" attachment in my previous post, then:

1) place "extract_preview.tar.gz" on your Desktop

2) double-click on "extract_preview.tar.gz" on your Desktop to unzip the "extract_preview" script.

3) Open a Terminal window and type these 2 commands (press the "return" key after each command):

cd ~/Desktop

./extract_preview /Volumes/250\ G/jennyjosh/raw/IMG_0887.CR2

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

scarchord

thx again for helping,

I ran the script for one image - and I got a 12KB preview (unusable - too bad). Any other ideas on how to get a bigger .jpg?

I tried running the script for the whole folder and nothing has come up, here is what terminal looks like:

Robs-MacBook-Pro:~ robc$ cd ~/Desktop
Robs-MacBook-Pro:Desktop robc$ ./extract_preview /Volumes/250\ G/jennyjosh/raw
[extract_preview version 1.01]
===== /Volumes/250 G/jennyjosh/raw/IMG_0882.CR2

Does that mean that it is hung up on one image "IMG_0882" is the first image in the folder.


anything else I can try?

thx again

scarchord

I was wrong, it is doing a batch extract on all those files - but it is taking a looooooong time. It's done 12 previews in 4 hours.

The previews, unfortunately, are too small to be used - all around 12 kb.

Are they normally this small?

thx

Phil Harvey

Wow, that's slow.  On my (really old) mac here, the script takes only about one second per file.  Odd.

I can't tell you if the size is normal without knowing what model of camera you are using.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

scarchord

hi again,
I shot met of these with Canon's 5D Mark II and Some with the Original 5D.
I'm on a brand new macbook Pro - my guess is that the files are so messed that it is causing things to go slow.
thx!

Phil Harvey

I'm not doing anything you couldn't do yourself, but I tried the script on a folder of good 5DmkII CR2 images and it extracted the 5616x3744 preview from each in about 0.7 seconds per file (1.83 GHz Intel Core Duo Mac Mini).  It could be that a messed up file would slow down things, but it would have to contain a lot of things that looked like JPEG headers to do this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

scarchord

OK, good to know.

At this point I think the files are beyond repair.

many thanks for all your help!

sikspak

Hola.  I recently shot a baseball game and 300 of my pictures are corrupted.  Since I was shooting in continuous I believe the camera was unable to properly save the images.  I've tried extracting thumbnails with exiftool to no avail.  Stating: unrecognized film format, or something like that.  I've also had my school try, and they unsuccessful, something not finding the beginning or the end of the file.  Anyways, this I beileve is the last stop before I say "screw it."

Phil Harvey

Send me an image and I'll take a look (my email is philharvey66 at gmail.com)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).