ExifTool Forum

ExifTool => ExifTool GUI => Topic started by: Beholder3 on January 15, 2012, 04:57:39 PM

Title: Extracting preview Image from PEF RAW file
Post by: Beholder3 on January 15, 2012, 04:57:39 PM
Hi,

I do not understand which command in exiftool direct I should use to extract the jpg preview image from a PEF (Pentax RAW format) file.
DNG works from the menu, but as I dont even understand the correct command line option for PEF I lack the knowledge to get it working in exiftool direct, where it woudl be nice to do this on all files selected int he GUI.

I tried "-b -JpgFromRaw" but that did nothing.
Title: Re: Extracting preview Image from PEF RAW file
Post by: BogdanH on January 16, 2012, 01:20:01 AM
Hi,
After selecting desired PEF file(s) in GUI, you should use:
-b -previewImage -w %f.jpg
or
-b -JpgFromRaw -w %f.jpg
which will create jpg files.

Bogdan
Title: Re: Extracting preview Image from PEF RAW file
Post by: Phil Harvey on January 16, 2012, 07:27:48 AM
I would suggest using %d%f.jpg so the output jpg goes into the same directory as the raw file.

- Phil
Title: Re: Extracting preview Image from PEF RAW file
Post by: Beholder3 on January 16, 2012, 07:47:56 AM
Thanks! I used "-b -BigImage -w %d%f.jpg" now, based on your recommendations here and in the other thread and that works nicely.



Title: Re: Extracting preview Image from PEF RAW file
Post by: Beholder3 on January 16, 2012, 07:53:50 AM
I use the most recent versions of GUI 4.26 and exiftool 8.75 but I seem to have one general issue with PEF files:

The GUI application freezes for pretty much exactly 30 seconds on choosing a single PEF-file in the center pane in standard view.
It doesn't happen with JPGs or DNGs. After that while I can continue normally. No error messages. GUI doesnt show any preview picture in the lower left corner.
During the freeze CPU load goes massively up on a core i7 (not flat).

Ideas?

Title: Re: Extracting preview Image from PEF RAW file
Post by: BogdanH on January 16, 2012, 12:15:33 PM
Hi,

I only have Pentax K-5 PEF file here right now and there's absolutely no delay when selecting this file. GUI will only show preview images of "known" image files. That is, only those of which Win Explorer can display thumbnails; for other (mostly raw) files, appropriate imaging codec must be installed -btw. I use FastPistureViewer codec.
What happens, if you turn "Details" button off (for showing thumbnails)? On smaller amount of PEF files, thumbnails should appear quite fast -if that's not the case, then you should check into this direction...

If you use some other (non K-5) PEF file.. is it possible you upload that file somewhere, so I could take a look? Otherwise, I could make an "tweaked" GUI, where you could disable showing preview in GUI -just to findout, if that's the reason.

Btw. use of -%d%f.jpg is actually not necessary in GUI, because GUI works on "current directory" principle: opened folder is always current/working folder. However, because ExifTool direct option is quite flexible, there might be cases where such option is desired.

Added:
Just got an example of 10D PEF file and I have no problem when selecting it inside GUI -as mentioned, I assume it's an "codec" issue.

Bogdan
Title: Re: Extracting preview Image from PEF RAW file
Post by: Beholder3 on January 17, 2012, 06:51:58 AM
I'll do some more testing later. I used a K-5 so that should be no difference.

As I just found it, I can share this:
http://www.rawsamples.ch/
You can find many different RAW file types there for testing.
The site is old, but the files are still ok.

PH Edit: Fixed broken link
Title: Re: Extracting preview Image from PEF RAW file
Post by: BogdanH on January 17, 2012, 02:04:23 PM
Hi,
Yes, "rawsamples.ch" -that's where I have got some of older raw files  :)
But as I have mentioned, here, GUI responds on selecting PEF (and other) files almost instantly -as if they were normal JPG files.
Did you try with some other raw files, i.e Canon CR2, Nikon NEF, etc.? That is, I still assume, that delay is caused by displaying PEF previews. And from GUI's prespective, there's no difference what file you select: if Windows can deliver preview, then GUI will show it. If Windows (codec, that is) is slow on this, then there's a delay.
You didn't say what (codec) software are you using for displaying thumbnails of PEF files in Windows Explorer?... I allready mentioned FastPictureView codec (~15$). I don't know if Pentax provides something for this purpose -if not, then you should try (free) ArcSoft thumbnail viewer:
http://www.arcsoft.com/estore/software_title.asp?ProductCode=RTV
-it's a bit older, so it might not support some newer raw files, but it works otherwise (for 32bit windows only!).

Bogdan
Title: Re: Extracting preview Image from PEF RAW file
Post by: Beholder3 on January 18, 2012, 04:51:02 AM
Hi,

I think I have the FastPicturevIewer 1.66 (the last free one) installed. And in addition to that the Pentax RAW Codec.
In Windows Explorer thumbnails for both JPEG, DNG, CR2 and PEF are generated quickly as usual. No problems there.

In exiftoolGUI there is also no issue with DNG or CR2. But still there is that freeze (mouse cursor is still moving though and other apllications run fine during the wait) in exiftoolGUI when I select a PEF file. This happens also when using the K200 PEF from the discussed website.

It seems when selecting the PEF the exif data is displayed quickly most of the time. Only after this something gets stuck and the preview is not shown. But I must repeat that windows explorer has no issues with the preview.

In sysinternals process explorer I can see that the CPU load is generated in the process dllhost under svchost and after a while the process werfault starts (which means there is an error somewhere) and ends. After werfault ends GUI works again.
dllhost the strings "error opening file" and "error opening process".
Title: Re: Extracting preview Image from PEF RAW file
Post by: BogdanH on January 18, 2012, 12:42:49 PM
Hi,
As mentioned, for showing preview, GUI doesn't care what kind of image is needed to be displayed. Even further: GUI actually doesn't check what kind of image that is. The only exception is jpg: if checked in GUI preferences, then GUI rotates image accordingly (because Windows doesn't use Orientation tag value). So, to put it simple, GUI sends the command to windows: "here's a file name, I need a image of Width x Height size" -and GUI will display whatever comes from Windows.
I am explaining this, just to emphasize, that GUI has no influence on speed (or quality) of displayed preview.

Now, why do you have two (FastPicture & Pentax) codec installed? This isn't the best practice, IMO... FastPictureView codec is actually not a "real" codec: by default, it only displays preview image which reside inside raw (and it does that very fast). On the other hand, original codecs usually deliver real (processed) raw image, which isn't that fast... and while previews comming from FastPicture codec are cached by Windows (to gain speed in next request), I have no idea how Pentax codec handles that.
A hint: I could use original (free) Canon codec for my photos... but I don't.

Bogdan
Title: Re: Extracting preview Image from PEF RAW file
Post by: Beholder3 on January 18, 2012, 05:19:52 PM
Hi,

I pushed the "Details" Button now to only show thumbnails. There the normal windows thumbnail shows up as in explorer with no problem. Only when I select it, GUI gets stuck.
The "display problem" I seem to perceive is not the thumbnails, but the "bigger" "preview" in the lower left corner. Thats not quickly displayed.
I'll fiddle around with installing and uninstalling the codecss now...
Title: Re: Extracting preview Image from PEF RAW file
Post by: Beholder3 on January 18, 2012, 05:25:36 PM
Did remove Pentax Raw codec. Now it works.  :o As you said.  ;) Man, what a sillyness. I assumed manufacturers should know it best. Wrong.
Anyhow - problem solved.
Title: Re: Extracting preview Image from PEF RAW file
Post by: BogdanH on January 19, 2012, 01:04:54 AM
Hi,
I'm glad to hear you solved this.

Bogdan
Title: Re: Extracting preview Image from PEF RAW file
Post by: Antanico on February 29, 2012, 05:22:57 PM

Hello Experts of EXIF,
As I am working with PEF files too and I cannot manage with the preview could you confirm that I need to remove the Pentax RAW codec?
Am I able to see the K5 activation shots then? (The numbers of picture that the camera took).
Kindet regards,
Ant
Title: Re: Extracting preview Image from PEF RAW file
Post by: Phil Harvey on March 01, 2012, 02:11:28 AM
Hi Ant,

ExifTool does extract ShutterCount for the K-5.  You should be able to see this if you fix your PEF problems.

- Phil
Title: Re: Extracting preview Image from PEF RAW file
Post by: BogdanH on March 01, 2012, 12:14:02 PM
Hi Ant,

If you have problems with showing PEF previews, mybe you should try the small utility provided here:
http://www.fastpictureviewer.com/forum/viewtopic.php?f=7&p=3119#p3119
..which should help you to identify if you have multiple WIC codecs installed for PEF file. If you get PEF decoder listed more than once, then you must remove some -because only one should be installed.

Bogdan
Title: Re: Extracting preview Image from PEF RAW file
Post by: Beholder3 on June 17, 2012, 04:14:49 PM
Quote from: BogdanH on January 16, 2012, 01:20:01 AM
After selecting desired PEF file(s) in GUI, you should use:
-b -JpgFromRaw -w %f.jpg
which will create jpg files.

Any idea why that command does not work on a DNG raw file in exiftoolGUI in the exiftool direct area?
Is DNG not a RAW file for it?

-b -BigImage -w %d%f.jpg and -b -previewImage -w %d%f.jpg work nicely on the same file.

By the way: What syntax would I need in the exiftool direct space for exiftool -b -ThumbnailImage MyPhoto.jpg>MyThumb.jpg?
Title: Re: Extracting preview Image from PEF RAW file
Post by: Phil Harvey on June 17, 2012, 08:49:02 PM
The names of JpgFromRaw and PreviewImage are somewhat arbitrary.  The idea was that a PreviewImage was usually smaller than the full RAW image, but the JpgFromRaw was the full size.  However, due to the inconsistent way these images are stored, this isn't always the case now.

- Phil
Title: Re: Extracting preview Image from PEF RAW file
Post by: BogdanH on June 18, 2012, 01:26:00 AM
Quote
exiftool -b -ThumbnailImage MyPhoto.jpg>MyThumb.jpg
-this command redirects output (output goes to disk instead on console window) and such commands doesn't work in ExifTool direct. That's because GUI allready redirects all ExifTool's output toward GUI.

Bogdan
Title: Re: Extracting preview Image from PEF RAW file
Post by: Phil Harvey on June 18, 2012, 07:41:52 AM
Quote from: BogdanH on June 18, 2012, 01:26:00 AM
-this command redirects output (output goes to disk instead on console window) and such commands doesn't work in ExifTool direct. That's because GUI allready redirects all ExifTool's output toward GUI.

Yes, but you should be able to use the -o option instead.  Perhaps like this in the ExifToolGUI direct feature:

-thumbnailimage -b -o %d/%f_thumb.jpg

- Phil
Title: Re: Extracting preview Image from PEF RAW file
Post by: BogdanH on June 18, 2012, 11:56:09 AM
Hi Phil,
I have a problem with above command. I have tried it in console windows too:
exiftool -ThumbnailImage -b -o %f_thumb.jpg src.CR2
..but I get the same result as from ExifTool direct:
Error: Can't create JPEG files from other types
Am I using the command correctly? I am interested on this, because I hope I could create csv file by using -o option.

Bogdan
Title: Re: Extracting preview Image from PEF RAW file
Post by: Phil Harvey on June 18, 2012, 12:18:51 PM
Ooopsie.  Sorry.  That should be -w, not -o.  :(

But unfortunately, -w creates one file for each input file, so it probably won't do what you want for the .csv output.

- Phil
Title: Re: Extracting preview Image from PEF RAW file
Post by: Beholder3 on June 18, 2012, 12:33:07 PM
Quote from: Phil Harvey on June 17, 2012, 08:49:02 PM
The names of JpgFromRaw and PreviewImage are somewhat arbitrary.  The idea was that a PreviewImage was usually smaller than the full RAW image, but the JpgFromRaw was the full size.  However, due to the inconsistent way these images are stored, this isn't always the case now.

So you are telling me I should forget this command option since it is not gonna work on my DNG file?
(not an issue, since the others work, just curious)
Title: Re: Extracting preview Image from PEF RAW file
Post by: Beholder3 on June 18, 2012, 12:35:23 PM
Quote from: Phil Harvey on June 18, 2012, 12:18:51 PM
Ooopsie.  Sorry.  That should be -w, not -o.  :(
But unfortunately, -w creates one file for each input file, so it probably won't do what you want for the .csv output.

When I have a single DNG file selected in exiftoolGUI and run -ThumbnailImage -b -w %f_thumb.jpg pretty much nothing happens. No output file created.
Title: Re: Extracting preview Image from PEF RAW file
Post by: Phil Harvey on June 18, 2012, 12:52:51 PM
Some DNG images just don't contain embedded JPEG's.  If yours is one of these, then the command won't work.

Sorry, I got hung up initially on the difference between PreviewImage and JpgFromRaw, which is sort of off topic (since using BigImage avoids this problem).

- Phil
Title: Re: Extracting preview Image from PEF RAW file
Post by: BogdanH on June 18, 2012, 01:52:22 PM
I'm somehow lost now.. I have original Pentax K-5.DNG file here.
This works:
exiftool -b -PreviewImage -w Thumb.jpg Pentax.DNG
-and extracts "medium size" preview (640x480). As far I can tell, this is defined in MakerNote section.

As Beholder3 said, this does nothing:
exiftool -b -ThumbnailImage -w Thumb.jpg Pentax.DNG
-I believe thumbnail (160x120) is defined in IFD0. Btw. this command works for CR2 files -so command used is correct.

Now, "full" preview seems to be defined in SubIFD1 section, but I can't access it neither with -PreviewImage or -JpgFromRaw (probably stupid, but I also tried with -SubIFD1:PreviewImage).
And now I have noticed you have mentiond -BigImage option, which again, does nothing for Pentax.DNG. I've looked here: http://www.exiftool.org/exiftool_pod.html but couldn't find any info about -BigImage (how/when to use).

Phil, am I interpreting your words right, when you say that previews inside DNG files are incosistent in regard of sections where they reside? And if that's true, is there a way to force pulling preview from particular (i.e. from SubIFD1) section?

Bogdan
Title: Re: Extracting preview Image from PEF RAW file
Post by: Beholder3 on June 18, 2012, 05:27:26 PM
Guys, you are making my head spin.I have a DNG file here, straight out of a Pentax K-5 camera.

-b -BigImage -w %d%f.jpg works nicely, it extracts the 16 megapixel preview JPG.
-b -previewImage -w %d%f.jpg also works nicely it, extracts the 640 x 480 small thumbnail image.

On the same DNG file
-ThumbnailImage -b -w %f_thumb.jpg just does nothing (when executed via exiftoolGUI/exiftool direct).This does in no way fit to your comments. ???

PS:
The exiftoolGUI menu entry "export/import" / "extract preview from selected" gets me only the 640 x480 image from that DNG file.

PPS:
If that is of any interest: the metadata export into text file for that DNG contains the following three entries:

Quote---- Composite ----
Preview Image                   : (Binary data 1495796 bytes, use -b option to extract)
Preview Image                   : (Binary data 35502 bytes, use -b option to extract)
Big Image                       : (Binary data 1495796 bytes, use -b option to extract)

I created this .txt-file using GUI's menu option "Import/export" / "Export metadata into" / "TXT files".

PPS:
I just tried with 3 more DNG pictures of various age. The two abovementioned commands to extract the small and big previews always worked, while the third never does.

PPPS:
I just converted a Pentax K-5 created JPG into DNG via Lightroom 4.1 using the default DNG export.

The small preview also can be extracted using the abovementioned commands. It is 1024 x 678 pixels now though and I get the warning in exiftool "Warning: Bad MakerNotes offset for tag 0x406"
And ... using the BigImage command now gets me the exact same small 1024 x 678 pixel preview, not a fullsize preview as the ooC file did. Also the same warning.

Metadata textfile only shows this:

Quote---- Composite ----
Preview Image                   : (Binary data 45278 bytes, use -b option to extract)
Big Image                       : (Binary data 45278 bytes, use -b option to extract)





Title: Re: Extracting preview Image from PEF RAW file
Post by: BogdanH on June 19, 2012, 01:17:49 AM
I must have one of the first (firmware) images from K-5 (taken from Imaging Resource). And for this file, composite tag BigImage isn't listed -but, as mentioned, preview image seems to be in SubIFD1 section.
I think that's what makes differences and causes consfusion here.

Bogdan
Title: Re: Extracting preview Image from PEF RAW file
Post by: Beholder3 on June 19, 2012, 07:12:46 AM
Strange. I wonder how Imagingressource created their RAWs.

You can take this here from DPReview:
http://movies.dpreview.com.s3.amazonaws.com/pentax_k5/IMGP3854.DNG.zip
It is also from firmware v1.0 (I used 1.13) and it already has both previews in it.

Quote
Preview Image                   : (Binary data 1301794 bytes, use -b option to extract)
Preview Image                   : (Binary data 40184 bytes, use -b option to extract)
Big Image                       : (Binary data 1301794 bytes, use -b option to extract)

Maybe you use this.
Title: Re: Extracting preview Image from PEF RAW file
Post by: Phil Harvey on June 19, 2012, 08:01:33 AM
For images from my K-5 when I got it new:

> exiftool ../pics/PentaxK-5* | grep -E '(===|Binary|Software)'
======== ../pics/PentaxK-5.dng
Software                        : K-5 Ver 1.00
Preview Image                   : (Binary data 1155571 bytes, use -b option to extract)
Preview Image                   : (Binary data 35349 bytes, use -b option to extract)
Big Image                       : (Binary data 1155571 bytes, use -b option to extract)
======== ../pics/PentaxK-5.pef
Software                        : K-5 Ver 1.00
Jpg From Raw                    : (Binary data 1180544 bytes, use -b option to extract)
Preview Image                   : (Binary data 36179 bytes, use -b option to extract)
Thumbnail Image                 : (Binary data 7710 bytes, use -b option to extract)
Big Image                       : (Binary data 1180544 bytes, use -b option to extract)


This DNG has two PreviewImage's and doesn't contain a ThumbnailImage.

- Phil
Title: Re: Extracting preview Image from PEF RAW file
Post by: BogdanH on June 19, 2012, 12:02:43 PM
Quote from: Beholder3 on June 19, 2012, 07:12:46 AM
You can take this here from DPReview:
http://movies.dpreview.com.s3.amazonaws.com/pentax_k5/IMGP3854.DNG.zip
I just did that and here (again) I get nothing from this file by using:
exiftool -b -BigImage -w %f.jpg IMGP3854.DNG
-and BigImage also isn't listed in Composite (I have latest ExifTool v8.95). Now I am really getting curious  ???

Bogdan
Title: Re: Extracting preview Image from PEF RAW file
Post by: Beholder3 on June 19, 2012, 12:08:54 PM
Huh?
I just upgraded to 8.95 but still I get the BigImage using exiftoolGUI.
???

Using Windows 7 64bit Ultimate, exiftoolGui 5.14 and exiftool 8.95.
Title: Re: Extracting preview Image from PEF RAW file
Post by: Beholder3 on June 19, 2012, 12:10:56 PM
One question to Phil as add on:
Does that actually mean, these files (DNG/PEF) really do contain the same fullsize "preview" JPG twice, each stored in a different "area"? or is it only two "pointers" pointing to the same JPGs?
Title: Re: Extracting preview Image from PEF RAW file
Post by: Phil Harvey on June 19, 2012, 12:13:30 PM
The Composite BigImage tag is just a duplicate of the biggest JPG image in the file.

There are 2 PreviewImage's in the DNG, but they are different (different resolutions and file sizes).

Regarding the BigImage confusion:  This is one of the user-defined tags in the sample config file.  So Beholder3 must have the sample config file installed.

- Phil
Title: Re: Extracting preview Image from PEF RAW file
Post by: BogdanH on June 19, 2012, 12:19:27 PM
I've downloaded ExifTool again, deleted "par" directory in Temp, and ran above command again -same result: BigImage isn't there. To be sure, I've executed command in console too. Otherwise, same GUI version, and Win7 x64.
Are we using the same IMGP3854.DNG image? I mean, this IS weird.

Bogdan
Title: Re: Extracting preview Image from PEF RAW file
Post by: Beholder3 on June 19, 2012, 12:22:01 PM
Quote from: Phil Harvey on June 19, 2012, 12:13:30 PM
Regarding the BigImage confusion:  This is one of the user-defined tags in the sample config file.  So Beholder3 must have the sample config file installed.

Ah, yes.  :) Just checked it. I must have inserted the code into the config file some months ago when I first played around with the preview extraction. I forgot about it and assumed its "standard".

That is the code in .ExifTool_config

# [advanced] select largest JPEG preview image
        BigImage => {
        Desire => {
            0 => 'JpgFromRaw',
            1 => 'PreviewImage',
            2 => 'OtherImage',
            # (DNG and A100 ARW may be have 2 PreviewImage's)
            3 => 'PreviewImage (1)',
                },
        # ValueConv may also be a code reference
        # Inputs: 0) reference to list of values, 1) ExifTool object
        ValueConv => sub {
            my $val = shift;
            my ($image, $bigImage, $len, $bigLen);
            foreach $image (@$val) {
            next unless ref $image eq 'SCALAR';
            # check for JPEG image (or "Binary data" if -b not used)
            next unless $$image =~ /^(\xff\xd8\xff|Binary data (\d+))/;
            $len = $2 || length $$image; # get image length
            # save largest image
            next if defined $bigLen and $bigLen >= $len;
            $bigLen = $len;
            $bigImage = $image;
                    }
            return $bigImage;
Title: Re: Extracting preview Image from PEF RAW file
Post by: BogdanH on June 19, 2012, 12:45:14 PM
That explains a lot  :) Thank you.

Bogdan
Title: Re: Extracting preview Image from PEF RAW file
Post by: Beholder3 on June 19, 2012, 01:52:00 PM
Sorry. I found one more thing in this DNG:

Quote---- ExifTool ----
ExifTool Version Number         : 8.95
---- File ----
File Name                       : IMGP3854.DNG
Directory                       : .
File Size                       : 22 MB
File Modification Date/Time     : 2010:12:16 18:50:58+01:00
File Permissions                : rw-rw-rw-
File Type                       : DNG
MIME Type                       : image/x-adobe-dng
Exif Byte Order                 : Big-endian (Motorola, MM)
---- EXIF ----
Subfile Type                    : Reduced-resolution image
Image Width                     : 160
Image Height                    : 120


For one there seems to be no such preview file in there which should be extractable, as we learned there are no real small thumbnails in there in the DNG.

For two in the output at the same time I can find nothing about a Reduced resolution image with 640 x 480 which is actually extractable.

I see three options:

a) There is a mini 160x120 preview which we cant yet extract plus there is a 640x480 preview which doesnt show in exiftools output in detail
b) there is a mini 160x120 preview in there and it is being saved in a blown up way (dont really believe this)
c) exiftool misinterprets the dimensions by factor 4.


Title: Re: Extracting preview Image from PEF RAW file
Post by: Phil Harvey on June 19, 2012, 02:03:26 PM
The option is a).

The 160x120 preview is not extracted by ExifTool because it is not JPEG format.  (Look at the Compression tag)

- Phil