OBS User unknown 2007-01-15 23:08:44 +00:00 committed by Git OBS Bridge
commit 3bf47c2bac
14 changed files with 9370 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

612
README Normal file
View File

@ -0,0 +1,612 @@
http://www.cybercom.net/~dcoffin/dcraw/:
[1]Back to Dave Coffin's Home Page
[2]en Esperanto
Welcome! If you are wondering how to connect your digital camera and
download images to a Linux PC, go to the [3]gPhoto homepage. My
software is for processing those images after downloading them.
If you're downloading JPEG files, you don't need my software at all.
The image has already been processed inside the camera. Almost all
digital cameras made since 1997 produce JPEG images, so why would you
want to do it any other way?
Well, despite the convenience and ubiquity of JPEG, there are some
disadvantages. JPEG is a lossy format -- to fit a big image into a
small file, a lot of information is thrown away. That's why midrange
and high-end digital cameras offer an alternative: Raw, unprocessed
CCD data files, for which the camera manufacturer provides special
decoding software.
Of course this software is for Windows and Macintosh only, with no
source code. So it's useless to users of other operating systems,
programmers hoping to design a better interpolation algorithm, and
historians not yet born in an era when the only Windows machines will
be in museums.
So here is my mission: Write and maintain an ANSI C program that
decodes any raw image from any digital camera on any computer running
any operating system.
That program is called [4]dcraw (pronounced "dee-see-raw"), and it's
become a standard tool within and without the Open Source world. It's
small (about 7000 lines), portable (standard C libraries only), free
(both "gratis" and "libre"), and when used skillfully, produces
[5]better quality [6]output than the tools provided by the camera
vendor.
[7]Here's my resume. I do freelance consulting related to dcraw, and
I'm also available for full-time software work in the Northeast USA.
I can be reached by sending e-mail to cybercom dot net with the
username "dcoffin".
My Code
Unless otherwise noted in the source code, these programs are free for
all uses, although I would like to receive credit for them. Donations
are welcome too, if you're making money from my code.
Note to Linux distributors: The only executable files that should be
installed by a dcraw package are "dcraw", "clean_crw", and maybe
"fuji_green", "fujiturn", and "fujiturn16". My shell scripts are
dangerous and should only be installed in a "doc" directory without
execute permission.
* [8]dcraw.c -- decodes raw photos, extracts thumbnails, and
displays metadata
Supports 231 cameras at last count. Compile with "gcc -o dcraw -O4
dcraw.c -lm -ljpeg -llcms" or "gcc -o dcraw -O4 dcraw.c -lm
-DNO_JPEG -DNO_LCMS". Run with no arguments to see a usage
message. Don't complain that 16-bit output is too dark -- read the
FAQ!
* [9]rawphoto.c -- basic plugin for GIMP 1.2 & 2.0
After installing "dcraw", do "gimptool --install rawphoto.c". My
plugin provides a simple dialog box for loading raw files into the
Gimp. [10]Udi Fuchs and [11]Joseph Heled have written much nicer
plugins, with live preview, histograms, and color curves.
* [12].badpixels -- my camera's "hot pixels"
This file tells dcraw which pixels have died and when, so that it
can interpolate around them.
* [13]dcraw.1 -- UNIX manpage for dcraw
Contains details and helpful hints not found elsewhere.
* [14]dcraw.c,v -- complete unabridged RCS file
This file contains the entire history of dcraw.c since its
conception on February 23, 1997. If you don't have the RCS
toolkit, [15]download it here.
* [16]parse.c -- read image data structures
This program displays CIFF and TIFF data structures in a very
cryptic format.
* [17]clean_crw.c -- clean Canon CRW files
Recovered or undeleted CRW files often have junk appended to them
that makes them unreadable. This program safely cleans CRW files.
* [18]fujiturn.c -- rotate Fuji Super CCD images
An alternative to dcraw's built-in Fuji rotation.
* [19]fuji_green.c -- convert Fuji green pixels to PGM
A side benefit of the Fuji Super CCD design is that its green
pixels make nice greyscale images.
For hackers only:
* [20]decompress.c is a simple reference decompressor for CRW files.
* [21]sony_clear.c decrypts SRF files from the Sony DSC-F828.
Other Raw Photo Decoders
Dcraw has made it far easier for developers to support a wide range of
digital cameras in their applications. They can call dcraw from a
graphical interface, paste pieces of dcraw.c into their code, or just
use dcraw.c as the documentation that camera makers refuse to provide:
* [22]ACDSee
* [23]Adobe Photoshop
* [24]BR's PhotoArchiver by Baard Riiber
* [25]BreezeBrowser by Chris Breeze
* [26]Conceiva Lightbox
* [27]cPicture by Jürgen Eidt
* [28]Cumulus by Canto
* [29]dcRAW-X by Bryan Chang
* [30]DCRawUI by Sune Trudslev
* [31]Directory Opus Plugin by Leo Davidson(with C++ source code)
* [32]DeepSkyStacker by Luc Coiffier
* [33]dpMagic by Mikhail Stolpner
* [34]EasyRaw Studio
* [35]GraphicConverter by Thorsten Lemke
* [36]GVBox from JCO Consulting
* [37]ImageLab from Aragon System
* [38]IrfanView by Irfan Skiljan
* [39]IRIS image processor for astronomers
* [40]KA Photoservice
* [41]Lightbox by Josh Anon
* [42]LightZone by Anton Kast
* [43]Photo Companion by Jeff Moore
* [44]Photo Jockey by Davie Lee Reed who also wrote a [45]dcraw
interface for Delphi programmers.
* [46]Photo Organizer by Balint Kis
* [47]PhotoReviewer by Ben Haller
* [48]Picasa from Google
* [49]Picture Arena by Felix Schwarz
* [50]PixInsight by Pleiades Software
* [51]PiXPO by How2Share Technologies
* [52]PolyView by Polybytes
* [53]PowerShovel-II by Luc Minnebo
* [54]RAW Developer by Iridient Digital
* [55]Raw Magick
* [56]RawConvert by Jason Swain
* [57]RawDrop by Frank Siegert
* [58]RawShooter from pixmantec
* [59]RawView by Jari Savolainen
* [60]Serif PhotoPlus, PanoramaPlus, and AlbumPlus
* [61]SharpRaw by Duane DeSieno
* [62]SilverFast DCPro by LaserSoft Imaging
* [63]StudioLine Photo by H&M Software
* [64]ViewIt by Zdzislaw Losvik
* [65]Viewer n5 by Dmitry Fedorov
* [66]VueScan by Ed Hamrick
Frequently Asked Questions
I don't have a C compiler. Could you send me an executable?
No, but Francisco Montilla provides Mac OS and Windows
executables [67]on his website. And Benjamin Lebsanft has
volunteered to maintain [68]Windows executables optimized for
specific CPUs.
If you're familiar with the DOS command line but don't know C,
you can install this [69]free C compiler for Windows and
compile dcraw.c quite easily.
How can I read the EXIF data (shutter speed, aperture, etc.)?
[70]Phil Harvey's ExifTool provides a unified Perl-based EXIF
reader (and editor!) for all cameras and file formats. "dcraw
-i -v" is much faster, but provides less information.
How can I read NEF files from Nikon scanners?
Dcraw only supports cameras. Try [71]this simple program for
scanners.
How can I read Nikon Dust Off images (NDF files)?
[72]Use this program.
Do you have any specifications describing raw photo formats?
Yes, but they tend to omit important details, like how to
decompress the raw image or decrypt private metadata. See the
[73]TIFF spec, the [74]TIFF/EP spec, the [75]Adobe DNG spec,
the [76]CIFF (CRW) spec, and the [77]X3F spec.
I'm designing a digital camera. How do I convert its raw photos into
something that dcraw and Adobe Photoshop can open?
Download [78]LibTIFF v3.8.0 and apply [79]this patch. Then use
[80]this C program as a template for converting your photos to
valid [81]Adobe DNG files.
I shot a raw photo with no light. Why does it appear all noisy, when
it should be solid black?
No matter how dark an image is, dcraw's auto-exposure stretches
it so that one percent of its pixels appear white. The "-b"
option adjusts this behavior, while "-4" (16-bit output) avoids
it entirely.
I bracket plus/minus two stops, but all five shots look almost the
same in dcraw. Why?
See the previous question.
Why is 16-bit output dark / unreadable?
If you want pretty pictures straight out of dcraw, stay with
8-bit output. 16-bit linear output is the best raw material for
professional image editors such as [82]Photoshop and
[83]CinePaint, but it's no good for most image viewers.
What does the "-f" (four color RGB) option do?
If you see patterns like [84]this or [85]this in your output
images, first try "dcraw -a". If these patterns persist, use
"dcraw -f" to get rid of them.
Could you please add an option for TIFF / FITS / PNG / BMP / JPEG
output?
In versions 8.25 and later, "dcraw -T" writes TIFF output with
metadata. To write other formats:
dcraw -c crw_0001.crw | pnmtofits > crw_0001.fits
dcraw -c crw_0001.crw | pnmtopng > crw_0001.png
dcraw -c crw_0001.crw | ppmtobmp > crw_0001.bmp
dcraw -c crw_0001.crw | cjpeg > crw_0001.jpeg
I used the [86]Netpbm toolkit in these examples.
[87]ImageMagick also does command-line format conversions. Both
are free.
Why don't you implement dcraw as a library?
I have decided that dcraw shall be a command-line program
written in C, and that any further abstraction layers must be
added around this core, not inside it.
Library code is ugly because it cannot use global variables.
Libraries are more difficult to modify, build, install, and
test than standalone programs, and so are inappropriate for
file formats that change every day.
There's a simpler way to make dcraw modular and thread-safe:
Run it as a separate process. Eric Raymond [88]explains this
technique here.
Why are there false colors along edges within the image?
Because of interpolation. This is a hard problem, easily
defined:
1. Take a three-color RGB image. At each pixel, set two color
values to zero.
2. Reconstruct the original three-color image as best you can
from the remaining one color per pixel.
Dcraw currently gives a choice of three methods: Bilinear,
Variable Number of Gradients (VNG), and Adaptive
Homogeneity-Directed (AHD).
[89]The Foveon X3 Capture chip requires a different kind of
interpolation. Unlike CCD arrays, it captures three colors at
every pixel location. But the colors are not well separated, so
the raw data looks very gray. Much processing is needed to
enhance color while suppressing noise.
How do I get my camera to take raw photos?
For some Nikon Coolpix cameras, you need to enable a
[90]special "DIAG RAW" mode.
For Casio cameras, see [91]Maurice Delaney's website or read
[92]this discussion on dpreview.
For the Minolta DiMAGE G400, G500, G530, or G600, go [93]here
(in Russian) or [94]here (in English).
For the Minolta DiMAGE Z2 and Nikon Coolpix 2100/3100/3700,
[95]go here.
For SMaL cameras, see the [96]camerahacking Forum.
For other cameras, refer to the User's Manual.
Does dcraw work with my camera?
Most likely, yes. If your camera is not on the list below, try
dcraw anyway. If it doesn't work, post a raw image to a website
and e-mail me the URL. If you don't have a website, use
[97]Dropload or [98]YouSendIt.
Ideally, your sample image should show a standard white card or
color chart in direct sunlight, with other colors in the
background.
Supported Cameras
* Adobe Digital Negative (DNG)
* AVT F-145C
* AVT F-201C
* AVT F-510C
* AVT F-810C
* Canon PowerShot 600
* Canon PowerShot A5
* Canon PowerShot A5 Zoom
* Canon PowerShot A50
* Canon PowerShot Pro70
* Canon PowerShot Pro90 IS
* Canon PowerShot G1
* Canon PowerShot G2
* Canon PowerShot G3
* Canon PowerShot G5
* Canon PowerShot G6
* Canon PowerShot S30
* Canon PowerShot S40
* Canon PowerShot S45
* Canon PowerShot S50
* Canon PowerShot S60
* Canon PowerShot S70
* Canon PowerShot Pro1
* Canon EOS D30
* Canon EOS D60
* Canon EOS 5D
* Canon EOS 10D
* Canon EOS 20D
* Canon EOS 30D
* Canon EOS 300D / Digital Rebel / Kiss Digital
* Canon EOS 350D / Digital Rebel XT / Kiss Digital N
* Canon EOS 400D / Digital Rebel XTi / Kiss Digital X
* Canon EOS D2000C
* Canon EOS-1D
* Canon EOS-1DS
* Canon EOS-1D Mark II
* Canon EOS-1D Mark II N
* Canon EOS-1Ds Mark II
* Casio QV-2000UX
* Casio QV-3000EX
* Casio QV-3500EX
* Casio QV-4000
* Casio QV-5700
* Casio QV-R51
* Casio QV-R61
* Casio EX-S100
* Casio EX-Z50
* Casio EX-Z55
* Casio Exlim Pro 505
* Casio Exlim Pro 600
* Casio Exlim Pro 700
* Contax N Digital
* Creative PC-CAM 600
* Epson R-D1
* Foculus 531C
* Fuji FinePix E550
* Fuji FinePix E900
* Fuji FinePix F700
* Fuji FinePix F710
* Fuji FinePix F800
* Fuji FinePix F810
* Fuji FinePix S2Pro
* Fuji FinePix S3Pro
* Fuji FinePix S20Pro
* Fuji FinePix S5000
* Fuji FinePix S5100/S5500
* Fuji FinePix S5200/S5600
* Fuji FinePix S7000
* Fuji FinePix S9000/S9500
* Imacon Ixpress 16-megapixel
* Imacon Ixpress 22-megapixel
* Imacon Ixpress 39-megapixel
* ISG 2020x1520
* Kodak DC20 (see [99]Oliver Hartman's page)
* Kodak DC25 (see [100]Jun-ichiro Itoh's page)
* Kodak DC40
* Kodak DC50
* Kodak DC120 (also try [101]kdc2tiff)
* Kodak DCS315C
* Kodak DCS330C
* Kodak DCS420
* Kodak DCS460
* Kodak DCS460A
* Kodak DCS520C
* Kodak DCS560C
* Kodak DCS620C
* Kodak DCS620X
* Kodak DCS660C
* Kodak DCS660M
* Kodak DCS720X
* Kodak DCS760C
* Kodak DCS760M
* Kodak EOSDCS1
* Kodak EOSDCS3B
* Kodak NC2000F
* Kodak ProBack
* Kodak PB645C
* Kodak PB645H
* Kodak PB645M
* Kodak DCS Pro 14n
* Kodak DCS Pro 14nx
* Kodak DCS Pro SLR/c
* Kodak DCS Pro SLR/n
* Kodak P850
* Kodak P880
* Kodak KAI-0340
* Konica KD-400Z
* Konica KD-510Z
* Leaf Aptus 17
* Leaf Aptus 22
* Leaf Aptus 65
* Leaf Aptus 75
* Leaf Cantare
* Leaf CatchLight
* Leaf CMost
* Leaf DCB2
* Leaf Valeo 6
* Leaf Valeo 11
* Leaf Valeo 17
* Leaf Valeo 22
* Leaf Volare
* Leica Digilux 2
* Leica D-Lux 2
* Logitech Fotoman Pixtura
* Micron 2010
* Minolta RD175
* Minolta DiMAGE 5
* Minolta DiMAGE 7
* Minolta DiMAGE 7i
* Minolta DiMAGE 7Hi
* Minolta DiMAGE A1
* Minolta DiMAGE A2
* Minolta DiMAGE A200
* Minolta DiMAGE G400
* Minolta DiMAGE G500
* Minolta DiMAGE G530
* Minolta DiMAGE G600
* Minolta DiMAGE Z2
* Minolta Alpha/Dynax/Maxxum 5D
* Minolta Alpha/Dynax/Maxxum 7D
* Nikon D1
* Nikon D1H
* Nikon D1X
* Nikon D2H
* Nikon D2Hs
* Nikon D2X
* Nikon D50
* Nikon D70
* Nikon D70s
* Nikon D80
* Nikon D100
* Nikon D200
* Nikon E700 ("DIAG RAW" hack)
* Nikon E800 ("DIAG RAW" hack)
* Nikon E880 ("DIAG RAW" hack)
* Nikon E900 ("DIAG RAW" hack)
* Nikon E950 ("DIAG RAW" hack)
* Nikon E990 ("DIAG RAW" hack)
* Nikon E995 ("DIAG RAW" hack)
* Nikon E2100 ("DIAG RAW" hack)
* Nikon E2500 ("DIAG RAW" hack)
* Nikon E3200 ("DIAG RAW" hack)
* Nikon E3700 ("DIAG RAW" hack)
* Nikon E4300 ("DIAG RAW" hack)
* Nikon E4500 ("DIAG RAW" hack)
* Nikon E5000
* Nikon E5400
* Nikon E5700
* Nikon E8400
* Nikon E8700
* Nikon E8800
* Olympus C3030Z
* Olympus C5050Z
* Olympus C5060WZ
* Olympus C7070WZ
* Olympus C70Z,C7000Z
* Olympus C740UZ
* Olympus C770UZ
* Olympus C8080WZ
* Olympus E-1
* Olympus E-10
* Olympus E-20
* Olympus E-300
* Olympus E-330
* Olympus E-500
* Olympus SP310
* Olympus SP320
* Olympus SP350
* Olympus SP500UZ
* Panasonic DMC-FZ30
* Panasonic DMC-FZ50
* Panasonic DMC-LC1
* Panasonic DMC-LX1
* Panasonic DMC-LX2
* Pentax *ist D
* Pentax *ist DL
* Pentax *ist DL2
* Pentax *ist DS
* Pentax *ist DS2
* Pentax K100D
* Pentax Optio S
* Pentax Optio S4
* Pentax Optio 33WR
* Phase One LightPhase
* Phase One H 10
* Phase One H 20
* Phase One H 25
* Phase One P 20
* Phase One P 25
* Phase One P 30
* Phase One P 45
* Pixelink A782
* Polaroid x530
* Rollei d530flex
* RoverShot 3320af
* Samsung GX-1S
* Sarnoff 4096x5440
* Sigma SD9
* Sigma SD10
* Sinar 3072x2048
* Sinar 4080x4080
* Sinar 4080x5440
* Sinar STI format
* SMaL Ultra-Pocket 3
* SMaL Ultra-Pocket 4
* SMaL Ultra-Pocket 5
* Sony DSC-F828
* Sony DSC-R1
* Sony DSC-V3
* Sony DSLR-A100
* Sony XCD-SX910CR
* STV680 VGA
_________________________________________________________________
References
1. http://www.cybercom.net/~dcoffin/
2. http://www.cybercom.net/~dcoffin/dcraw/index_eo.html
3. http://gphoto.sourceforge.net/
4. http://www.cybercom.net/~dcoffin/dcraw/dcraw.c
5. http://www.insflug.org/raw/
6. http://www.aim-dtp.net/aim/digicam/dcraw/
7. http://www.cybercom.net/~dcoffin/resume.html
8. http://www.cybercom.net/~dcoffin/dcraw/dcraw.c
9. http://www.cybercom.net/~dcoffin/dcraw/rawphoto.c
10. http://ufraw.sourceforge.net/
11. http://pages.quicksilver.net.nz/pepe/
12. http://www.cybercom.net/~dcoffin/dcraw/.badpixels
13. http://www.cybercom.net/~dcoffin/dcraw/dcraw.1
14. http://www.cybercom.net/~dcoffin/dcraw/RCS/dcraw.c,v
15. http://www.cs.purdue.edu/homes/trinkle/RCS/
16. http://www.cybercom.net/~dcoffin/dcraw/parse.c
17. http://www.cybercom.net/~dcoffin/dcraw/clean_crw.c
18. http://www.cybercom.net/~dcoffin/dcraw/fujiturn.c
19. http://www.cybercom.net/~dcoffin/dcraw/fuji_green.c
20. http://www.cybercom.net/~dcoffin/dcraw/decompress.c
21. http://www.cybercom.net/~dcoffin/dcraw/sony_clear.c
22. http://www.acdsystems.com/
23. http://www.adobe.com/products/photoshop/cameraraw.html
24. http://www.br-software.com/
25. http://www.breezesys.com/
26. http://www.conceiva.com/
27. http://cpicture.net/en/t_raw.html
28. http://www.canto.com/
29. http://frostyplace.com/dcraw/
30. http://www.tanis.dk/wiki/index.php/DCRawUI
31. http://www.pretentiousname.com/jp2raw/
32. http://deepskystacker.free.fr/
33. http://www.dpmagic.com/
34. http://www.easyraw.com/
35. http://www.lemkesoft.com/
36. http://jcoconsulting.com/index.asp?Section=GVOCX
37. http://www.aragonsystem.com/
38. http://www.irfanview.com/
39. http://www.astrosurf.com/buil/us/iris/iris.htm
40. http://www.kaorg.com/photoservice.asp
41. http://www.lightboxsoftware.com/
42. http://sonic.net/~rat/lightcrafts/
43. http://www.wildcape.com/
44. http://photojockey.com/
45. http://smatters.com/dcraw/
46. http://www.k-i-s.net/
47. http://www.sticksoftware.com/software/PhotoReviewer.html
48. http://www.picasa.com/
49. http://www.picturearena.com/
50. http://pleiades-astrophoto.com/
51. http://www.pixpo.com/
52. http://www.polybytes.com/
53. http://lens.liteserv.com/download/powershovel2.php
54. http://www.iridientdigital.com/
55. http://www.rawmagick.com/
56. http://www.i-graph.com/
57. http://www.wizards.de/rawdrop
58. http://www.pixmantec.com/
59. http://www.through-the-lens.net/
60. http://www.serif.com/
61. http://www.logicaldesigns.com/
62. http://www.silverfast.com/
63. http://www.studioline.net/
64. http://www.hexcat.com/viewit/
65. http://www.dimin.net/software/viewer/
66. http://www.hamrick.com/
67. http://www.insflug.org/raw/
68. http://www.lebsanft.org/blog/index.php?cat=9
69. http://www.delorie.com/djgpp/
70. http://www.sno.phy.queensu.ca/~phil/exiftool/
71. http://www.cybercom.net/~dcoffin/dcraw/scan.c
72. http://www.cybercom.net/~dcoffin/dcraw/read_ndf.c
73. http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf
74. http://www.map.tu.chiba-u.ac.jp/IEC/100/TA2/recdoc/N4378.pdf
75. http://www.adobe.com/products/dng/pdfs/dng_spec.pdf
76. http://xyrion.org/ciff/
77. http://www.x3f.info/technotes/FileDocs/X3F_Format.pdf
78. http://dl.maptools.org/dl/libtiff/tiff-3.8.0.tar.gz
79. http://www.cybercom.net/~dcoffin/dcraw/libtiff.patch
80. http://www.cybercom.net/~dcoffin/dcraw/elphel_dng.c
81. http://www.adobe.com/products/dng/main.html
82. http://www.adobe.com/products/photoshop/main.html
83. http://cinepaint.sourceforge.net/
84. http://www.cybercom.net/~dcoffin/dcraw/ahd_maze.png
85. http://www.cybercom.net/~dcoffin/dcraw/vng_grid.png
86. http://netpbm.sourceforge.net/
87. http://www.imagemagick.org/
88. http://www.faqs.org/docs/artu/multiprogramchapter.html
89. http://www.dpreview.com/news/0202/02021101foveonx3.asp
90. http://e2500.narod.ru/raw_format_e.htm
91. http://www.inweb.ch/foto/rawformat.html
92. http://forums.dpreview.com/forums/read.asp?forum=1015&message=4961779
93. http://myfototest.narod.ru/
94. http://forums.dpreview.com/forums/read.asp?forum=1024&message=11773287
95. http://tester13.nm.ru/nikon/
96. http://www.camerahacking.com/
97. http://dropload.com/
98. http://yousendit.com/
99. http://www.planet-interkom.de/oliver.hartmann/dc20secr.htm
100. http://www.itojun.org/diary/19961113/index.eng.html
101. http://kdc2tiff.sourceforge.net/

3
README.SuSE Normal file
View File

@ -0,0 +1,3 @@
To prevent name clashes, following tools from dcraw were renamed:
parse -> dcparse

34
badpixels Normal file
View File

@ -0,0 +1,34 @@
# .badpixels file for my Canon PowerShot G2, serial no. 4624504380
# dcraw will use this file if run in the same directory, or in any
# subdirectory.
# Always use "dcraw -d -j -t 0" when locating bad pixels!!
# Format is: pixel column, pixel row, UNIX time of death
# This pixel went bad between August 1 and 4, 2002
962 91 1028350000
# This pixel went bad between January 9 and 30, 2003
902 877 1043000000
# These are only visible in low light, so I haven't dated them:
621 943 0
1285 1067 0
1286 1067 0
2181 1532 0
# I swept these up 4/19/2005
763 36 1110000000
1827 466 1110000000
# low light
198 1288 1110000000
346 328 1110000000
429 273 1110000000
621 943 1110000000
624 874 1110000000
848 400 1110000000
1682 1686 1110000000
1892 1250 1110000000
2234 484 1110000000
2242 618 1110000000

204
dcraw.1 Normal file
View File

@ -0,0 +1,204 @@
.\"
.\" Man page for dcraw (Raw Photo Decoder)
.\"
.\" Copyright (c) 2006 by David Coffin
.\"
.\" You may distribute without restriction.
.\"
.\" David Coffin
.\" dcoffin a cybercom o net
.\" http://www.cybercom.net/~dcoffin
.\"
.TH dcraw 1 "July 18, 2006"
.LO 1
.SH NAME
dcraw - command-line decoder for raw digital photos
.SH SYNOPSIS
.B dcraw
[\fIOPTION\fR]... [\fIFILE\fR]...
.SH DESCRIPTION
.B dcraw
decodes raw photos, displays metadata, and extracts thumbnails.
.SH OPTIONS
.TP
.B -v
Print verbose messages, not just warnings and errors.
.TP
.B -c
Write decoded images or thumbnails to standard output.
.TP
.B -e
Extract the camera-generated thumbnail, not the raw image.
You'll get either a JPEG or a PPM file, depending on the camera.
.TP
.B -z
Change the access and modification times of an AVI, JPEG or raw
file to when the photo was taken, assuming that the camera clock
was set to Universal Time.
.TP
.B -i
Identify files but don't decode them.
Exit status is 0 if
.B dcraw
can decode the last file, 1 if it can't.
.B -i -v
shows metadata.
.TP
.B ""
.B dcraw
cannot decode JPEG files!!
.TP
.B -d
Show the raw data as a grayscale image with no interpolation.
Good for photographing black-and-white documents.
.TP
.B -D
Same as
.BR -d ,
but totally raw (no color scaling).
.TP
.B -h
Output a half-size color image. Twice as fast as
.BR -q\ 0 .
.TP
.B -q 0
Use high-speed, low-quality bilinear interpolation.
.TP
.B -q 2
Use Variable Number of Gradients (VNG) interpolation.
.TP
.B -q 3
Use Adaptive Homogeneity-Directed (AHD) interpolation.
.TP
.B -f
Interpolate RGB as four colors. Use this if the output shows
false 2x2 meshes with VNG or mazes with AHD.
.TP
.B -B sigma_domain sigma_range
Use a bilateral filter to smooth noise while preserving edges.
.B sigma_domain
is in units of pixels, while
.B sigma_range
is in units of CIELab colorspace.
Try
.B -B\ 2\ 4
to start.
.TP
.B -b brightness
By default,
.B dcraw
writes 8-bit PGM/PPM/PAM with a BT.709 gamma curve and a
99th-percentile white point. If the result is too light or
too dark,
.B -b
lets you adjust it. Default is 1.0.
.TP
.B -4
Write 16-bit linear pseudo-PGM/PPM/PAM with no gamma curve,
no white point, and no
.B -b
option.
.TP
.B -T
Write TIFF output (with metadata) instead of PGM/PPM/PAM.
.TP
.B -k black
Set the black point. Default depends on the camera.
.TP
.B -a
Automatic color balance. The default is to use a fixed
color balance based on a white card photographed in sunlight.
.TP
.B -w
Use the color balance specified by the camera.
If this can't be found, print a warning and revert to the default.
.TP
.B -r mul0 mul1 mul2 mul3
Specify your own raw color balance. These multipliers can be cut
and pasted from the output of
.BR dcraw\ -v .
.TP
.B -H 0
Clip all highlights to solid white (default).
.TP
.B -H 1
Leave highlights unclipped in various shades of pink.
.TP
.B -H 2-9
Reconstruct highlights. Low numbers favor whites; high numbers
favor colors. Try
.B -H 5
as a compromise. If that's not good enough, do
.BR -H\ 9 ,
cut out the non-white highlights, and paste them into an image
generated with
.BR -H\ 3 .
.TP
.B -m
Same as
.BR -o\ 0 .
.TP
.B -o [0-5]
Select the output colorspace when the
.B -p
option is not used:
.B \t0
\ \ Raw color (unique to each camera)
.br
.B \t1
\ \ sRGB D65 (default)
.br
.B \t2
\ \ Adobe RGB (1998) D65
.br
.B \t3
\ \ Wide Gamut RGB D65
.br
.B \t4
\ \ Kodak ProPhoto RGB D65
.br
.B \t5
\ \ XYZ
.TP
.BR -p\ camera.icm \ [\ -o\ output.icm \ ]
Use ICC profiles to define the camera's raw colorspace and the
desired output colorspace (sRGB by default).
.TP
.B -p embed
Use the ICC profile embedded in the raw photo.
.TP
.B -t [0-7,90,180,270]
Flip the output image. By default,
.B dcraw
applies the flip specified by the camera.
.B -t 0
disables all flipping.
.TP
.B -j
For Fuji\ Super\ CCD cameras, show the image tilted 45 degrees,
so that each output pixel corresponds to one raw pixel.
.TP
.B -s
For Fuji\ Super\ CCD\ SR cameras, use the secondary sensors, in
effect underexposing the image by four stops to reveal detail
in the highlights.
.TP
.B ""
For all other cameras,
.B -j
and
.B -s
are silently ignored.
.SH "SEE ALSO"
.BR pgm (5),
.BR ppm (5),
.BR pam (5),
.BR pnmgamma (1),
.BR pnmtotiff (1),
.BR pnmtopng (1),
.BR gphoto2 (1),
.BR cjpeg (1),
.BR djpeg (1)
.SH AUTHOR
Written by David Coffin, dcoffin a cybercom o net

7111
dcraw.c Normal file

File diff suppressed because it is too large Load Diff

104
dcraw.changes Normal file
View File

@ -0,0 +1,104 @@
-------------------------------------------------------------------
Mon Oct 16 22:47:15 CEST 2006 - postadal@suse.cz
- updated to RCS 1.353
* added support for Pentax K100D, Nikon D200, D80, E3200,
Canon EOS 400D, Panasonic DMC-LX2, DMC-FZ50
* correctly display long exposure times for CRW files
* added color matrices from Adobe DNG Converter 3.5
* display the focal length of Canon CRW images
-------------------------------------------------------------------
Thu Aug 17 17:35:46 CEST 2006 - postadal@suse.cz
- updated to RCS 1.340
* improved support for the Olympus E-330
-------------------------------------------------------------------
Wed Aug 2 12:35:19 CEST 2006 - postadal@suse.cz
- updated to RCS 1.338
* added "-H 2" option for rudimentary highlight recovery
* new "-T" option provides TIFF output with metadata and ICC profile
* replaced "-r" and "-l" options with raw white balance
* added support for Imacon Ixpress 22-Mp, Leaf Aptus 75, Leica D-Lux 2,
Sony DSLR-A100, Minolta DiMAGE G530, Sinar 4080x4080, Samsung GX-1S
* fixed camera WB for Canon EOS 10D, 300D, and clones
* added camera WB for the Kodak DCS Pro SLR models, Imacon Ixpress,
Kodak P850/P880
-------------------------------------------------------------------
Sun Mar 26 15:56:10 CEST 2006 - postadal@suse.cz
- updated to RCS 1.319
* new color matrix for the Nikon E700, E800, and E950
* new "-D" option to output unscaled raw pixels (totally raw)
* fixed defective pixels and columns in Phase One images
-------------------------------------------------------------------
Thu Feb 9 22:12:25 CET 2006 - dmueller@suse.de
- update to RCS 1.315 (#112733)
-------------------------------------------------------------------
Wed Feb 8 02:36:13 CET 2006 - dmueller@suse.de
- update to RCS 1.314:
Updated color matrices based on Adobe DNG Converter 3.3.
Added Kodak ProPhoto D65 as an output option.
-------------------------------------------------------------------
Thu Jan 26 12:29:16 CET 2006 - sbrabec@suse.cz
- Updated to dcraw v8, RCS 1.313.
- Added simple update_dcraw script.
-------------------------------------------------------------------
Wed Jan 25 21:35:24 CET 2006 - mls@suse.de
- converted neededforbuild to BuildRequires
-------------------------------------------------------------------
Wed Jan 11 15:56:34 CET 2006 - adrian@suse.de
- add stack protector compiler flag
-------------------------------------------------------------------
Thu Oct 13 13:48:05 CEST 2005 - postadal@suse.cz
- update to RCS 1.290
* added as default new interpolation algorithm AHD
(Adaptive homogeneity-directed demosaicing algorithm)
* new Bilateral filtering to remove color noises in CIELAB space
- update dcraw.1, fujiturn, dcparse (parse.c)
- removed crwfixdates (fixdates.c) superseded by "dcraw -z"
-------------------------------------------------------------------
Tue Jun 7 12:00:09 CEST 2005 - adrian@suse.de
- update to RCS 1.263
- compile with -fno-strict-aliasing to avoid compiler errors
-------------------------------------------------------------------
Fri Jun 3 12:46:05 CEST 2005 - postadal@suse.cz
- Updated to current version on maintainers website.
RCS version 1.262.
-------------------------------------------------------------------
Fri Feb 4 15:43:01 CET 2005 - meissner@suse.de
- Updated to current version on maintainers website.
RCS version 1.234.
-------------------------------------------------------------------
Thu Aug 26 14:05:18 CEST 2004 - sbrabec@suse.cz
- Updated to dcraw RCS version 1.200.
- Added more tools and documentation.
-------------------------------------------------------------------
Wed Jun 16 10:48:17 CEST 2004 - adrian@suse.de
- initial package of version 1.194

138
dcraw.spec Normal file
View File

@ -0,0 +1,138 @@
#
# spec file for package dcraw (Version 1.353)
#
# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# norootforbuild
Name: dcraw
BuildRequires: libjpeg-devel liblcms-devel
Version: 1.353
Release: 1
License: distributable, Other License(s), see package
Group: Productivity/Graphics/Convertors
URL: http://www.cybercom.net/~dcoffin/dcraw/
Summary: Raw Digital Photo Decoding
# NOTE: call "sh update_dcraw" to update to latest version.
Source: http://www.cybercom.net/~dcoffin/dcraw/dcraw.c
Source1: http://www.cybercom.net/~dcoffin/dcraw/dcraw.1
Source2: README
Source3: README.SuSE
Source4: badpixels
Source5: http://www.cybercom.net/~dcoffin/dcraw/dcwrap
Source7: http://www.cybercom.net/~dcoffin/dcraw/fujiturn.c
Source8: http://www.cybercom.net/~dcoffin/dcraw/parse.c
Source9: update_dcraw
Autoreqprov: on
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Command line tools for raw digital photo decoding and processing.
Authors:
--------
Dave Coffin
%prep
%setup -q -n . -D -T 0
cp -a %SOURCE0 %SOURCE1 %SOURCE2 %SOURCE3 %SOURCE4 %SOURCE5 %SOURCE7 %SOURCE8 .
mv badpixels .badpixels
chmod +x dcwrap
%build
export CFLAGS="$RPM_OPT_FLAGS"
%if %suse_version > 1000
export CFLAGS="$CFLAGS -fstack-protector-all"
%endif
for file in *.c ; do
LDFLAGS=
if test $file = dcraw.c ; then
LDFLAGS="-lm -ljpeg -llcms"
fi
gcc $CFLAGS -fno-strict-aliasing -o ${file%.c} $file $LDFLAGS
done
%install
mkdir -p $RPM_BUILD_ROOT/%_bindir
mkdir -p $RPM_BUILD_ROOT%_mandir/man1
install dcraw $RPM_BUILD_ROOT/%_bindir/
install -m 0644 dcraw.1 $RPM_BUILD_ROOT/%_mandir/man1/
install parse $RPM_BUILD_ROOT/%_bindir/dcparse
install fujiturn $RPM_BUILD_ROOT/%_bindir/
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%doc README README.SuSE .badpixels dcwrap
%_bindir/*
%doc %_mandir/man*/*
%changelog -n dcraw
* Mon Oct 16 2006 - postadal@suse.cz
- updated to RCS 1.353
* added support for Pentax K100D, Nikon D200, D80, E3200,
Canon EOS 400D, Panasonic DMC-LX2, DMC-FZ50
* correctly display long exposure times for CRW files
* added color matrices from Adobe DNG Converter 3.5
* display the focal length of Canon CRW images
* Thu Aug 17 2006 - postadal@suse.cz
- updated to RCS 1.340
* improved support for the Olympus E-330
* Wed Aug 02 2006 - postadal@suse.cz
- updated to RCS 1.338
* added "-H 2" option for rudimentary highlight recovery
* new "-T" option provides TIFF output with metadata and ICC profile
* replaced "-r" and "-l" options with raw white balance
* added support for Imacon Ixpress 22-Mp, Leaf Aptus 75, Leica D-Lux 2,
Sony DSLR-A100, Minolta DiMAGE G530, Sinar 4080x4080, Samsung GX-1S
* fixed camera WB for Canon EOS 10D, 300D, and clones
* added camera WB for the Kodak DCS Pro SLR models, Imacon Ixpress,
Kodak P850/P880
* Sun Mar 26 2006 - postadal@suse.cz
- updated to RCS 1.319
* new color matrix for the Nikon E700, E800, and E950
* new "-D" option to output unscaled raw pixels (totally raw)
* fixed defective pixels and columns in Phase One images
* Thu Feb 09 2006 - dmueller@suse.de
- update to RCS 1.315 (#112733)
* Wed Feb 08 2006 - dmueller@suse.de
- update to RCS 1.314:
Updated color matrices based on Adobe DNG Converter 3.3.
Added Kodak ProPhoto D65 as an output option.
* Thu Jan 26 2006 - sbrabec@suse.cz
- Updated to dcraw v8, RCS 1.313.
- Added simple update_dcraw script.
* Wed Jan 25 2006 - mls@suse.de
- converted neededforbuild to BuildRequires
* Wed Jan 11 2006 - adrian@suse.de
- add stack protector compiler flag
* Thu Oct 13 2005 - postadal@suse.cz
- update to RCS 1.290
* added as default new interpolation algorithm AHD
(Adaptive homogeneity-directed demosaicing algorithm)
* new Bilateral filtering to remove color noises in CIELAB space
- update dcraw.1, fujiturn, dcparse (parse.c)
- removed crwfixdates (fixdates.c) superseded by "dcraw -z"
* Tue Jun 07 2005 - adrian@suse.de
- update to RCS 1.263
- compile with -fno-strict-aliasing to avoid compiler errors
* Fri Jun 03 2005 - postadal@suse.cz
- Updated to current version on maintainers website.
RCS version 1.262.
* Fri Feb 04 2005 - meissner@suse.de
- Updated to current version on maintainers website.
RCS version 1.234.
* Thu Aug 26 2004 - sbrabec@suse.cz
- Updated to dcraw RCS version 1.200.
- Added more tools and documentation.
* Wed Jun 16 2004 - adrian@suse.de
- initial package of version 1.194

27
dcwrap Normal file
View File

@ -0,0 +1,27 @@
#!/bin/sh
# Rough equivalents to XV's Sharpen algorithm
cat > sharpen50.pgm << xx
P2 3 3 18
8 8 8 8 26 8 8 8 8
xx
cat > sharpen66.pgm << xx
P2 3 3 18
7 7 7 7 34 7 7 7 7
xx
cat > sharpen75.pgm << xx
P2 3 3 6
2 2 2 2 14 2 2 2 2
xx
cat > sharpen90.pgm << xx
P2 3 3 2
0 0 0 0 10 0 0 0 0
xx
for x in `ls *.crw | cut -d. -f1`
do
dcraw -f -c $x.crw | pnmconvol sharpen66.pgm \
| cjpeg -quality 90 > $x.jpeg
touch -r $x.crw $x.jpeg
done

102
fujiturn.c Normal file
View File

@ -0,0 +1,102 @@
/*
fujiturn.c by Dave Coffin
UNIX filter to correct the 45-degree rotation in images from
Fuji digital cameras. Compile with -D_16BIT to rotate 48-bit
PPM images. Sample usage:
dcraw -c -j dscf0000.raf | fujiturn | pnmscale 0.70710678 > dscf0000.ppm
$Revision: 1.6 $
$Date: 2005/04/29 16:35:42 $
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#ifdef _16BIT
typedef unsigned short value;
#else
typedef unsigned char value;
#define ntohs(x) (x)
#define htons(x) (x)
#endif
void merror (void *ptr, char *what)
{
if (ptr) return;
fprintf (stderr, "Not enough memory for %s\n", what);
exit(1);
}
int main()
{
FILE *ifp, *ofp;
value (*in)[3], (*mid)[3], (*pix)[3], (*out)[3];
char nl;
int maxval, i, j, iwide, ihigh, owide, ohigh;
unsigned irow, icol, orow, ocol;
#if defined(WIN32) || defined(DJGPP)
if (setmode(0,O_BINARY) < 0) perror("setmode(0)");
if (setmode(1,O_BINARY) < 0) perror("setmode(1)");
#endif
ifp = stdin;
ofp = stdout;
if (fscanf (ifp, "P6 %d %d %d%c", &iwide, &ihigh, &maxval, &nl) != 4
|| abs(iwide - ihigh) > 1) {
fprintf (stderr, "Input is not a Fuji image processed by dcraw.\n");
exit(1);
}
i = (maxval > 255) ? 16 : 8;
j = 8 * sizeof (value);
if (i != j) {
fprintf (stderr, "Input is %d-bit, fujiturn is %d-bit\n", i, j);
exit(1);
}
in = calloc (iwide, sizeof *in);
merror (in, "input array");
fread (in, iwide, sizeof *in, ifp);
for (i = 0; i < iwide; i++)
if (in[i][0] || in[i][1] || in[i][2]) break;
ohigh = (iwide - i) * 2 - 4;
for (i = iwide; --i;)
if (in[i][0] || in[i][1] || in[i][2]) break;
owide = i;
mid = calloc (ohigh * owide, sizeof *mid);
merror (mid, "middle array");
for (irow = 0; irow < ihigh; irow++) {
for (icol = 0; icol < iwide; icol++) {
orow = irow + icol - owide + 5;
ocol = (icol - irow + owide - 1)/2;
if (orow < ohigh && ocol < owide)
for (i = 0; i < 3; i++)
mid[orow*owide+ocol][i] = ntohs(in[icol][i]);
}
fread (in, iwide, sizeof *in, ifp);
}
free(in);
out = calloc (2*owide, sizeof *out);
merror (out, "output array");
fprintf (ofp, "P6\n%d %d\n%d\n", owide*2, ohigh, maxval);
for (orow = 0; orow < ohigh; orow++) {
for (ocol = 0; ocol < owide*2; ocol++) {
pix = mid + orow*owide + ocol/2;
if ((orow+ocol) & 1) {
if (orow-1 < ohigh-2 && ocol-1 < owide*2-2)
for (i = 0; i < 3; i++)
out[ocol][i] = htons (
( pix[-owide][i] + pix[0-(orow&1)][i] +
pix[ owide][i] + pix[1-(orow&1)][i] ) >> 2);
} else
for (i = 0; i < 3; i++)
out[ocol][i] = htons(pix[0][i]);
}
fwrite (out, 2*owide, 3*sizeof (value), ofp);
}
free(mid);
free(out);
return 0;
}

991
parse.c Normal file
View File

@ -0,0 +1,991 @@
/*
Raw Photo Parser
Copyright 2004-2006 by Dave Coffin, dcoffin a cybercom o net
This program displays raw metadata for all raw photo formats.
It is free for all uses.
$Revision: 1.62 $
$Date: 2006/08/18 02:51:53 $
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#ifdef WIN32
#include <winsock2.h>
typedef __int64 INT64;
#else
#include <netinet/in.h>
typedef long long INT64;
#endif
/*
TIFF and CIFF data blocks can be quite large.
Display only the first DLEN bytes.
*/
#ifndef DLEN
#define DLEN 768
#endif
#define ushort UshORt
typedef unsigned char uchar;
typedef unsigned short ushort;
FILE *ifp;
short order;
char *fname, make[128], model[128], model2[128];
int is_dng;
ushort sget2 (uchar *s)
{
if (order == 0x4949) /* "II" means little-endian */
return s[0] | s[1] << 8;
else /* "MM" means big-endian */
return s[0] << 8 | s[1];
}
#define sget2(s) sget2((uchar *)s)
ushort get2()
{
uchar str[2] = { 0xff,0xff };
fread (str, 1, 2, ifp);
return sget2(str);
}
int sget4 (uchar *s)
{
if (order == 0x4949)
return s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24;
else
return s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3];
}
#define sget4(s) sget4((uchar *)s)
int get4()
{
uchar str[4] = { 0xff,0xff,0xff,0xff };
fread (str, 1, 4, ifp);
return sget4(str);
}
float int_to_float (int i)
{
union { int i; float f; } u;
u.i = i;
return u.f;
}
double get_double()
{
union { char c[8]; double d; } u;
int i, rev;
rev = 7 * ((order == 0x4949) == (ntohs(0x1234) == 0x1234));
for (i=0; i < 8; i++)
u.c[i ^ rev] = fgetc(ifp);
return u.d;
}
void tiff_dump(int base, int tag, int type, int count, int level)
{
int save, j, num, den;
uchar c;
int size[] = { 1,1,1,2,4,8,1,1,2,4,8,4,8 };
if (count * size[type < 13 ? type:0] > 4)
fseek (ifp, get4()+base, SEEK_SET);
save = ftell(ifp);
printf("%*stag=0x%x %d, type=%d, count=%d, offset=%06x, data=",
level*2, "", tag, tag, type, count, save);
if (tag == 34310) goto quit;
if (type==2) putchar('\"');
for (j = 0; j < count && j < DLEN; j++)
switch (type) {
case 1: case 6: case 7: /* byte values */
printf ("%c%02x",(j & 31) || count < 17 ? ' ':'\n', fgetc(ifp) & 0xff);
break;
case 2: /* null-terminated ASCII strings */
c = fgetc(ifp);
putchar(isprint(c) ? c:'.');
break;
case 3: case 8: /* word values */
printf ("%c%04x",(j & 15) || count < 9 ? ' ':'\n', get2());
break;
case 4: case 9: /* dword values */
printf ("%c%08x",(j & 7) || count < 5 ? ' ':'\n', get4());
break;
case 5: case 10: /* rationals */
num = get4();
den = get4();
printf (" %d/%d", num, den);
// printf (" %lf", (double) num/den);
break;
}
if (type==2) putchar('\"');
quit:
putchar('\n');
fseek (ifp, save, SEEK_SET);
}
void parse_nikon_capture_note (int length)
{
unsigned sorder, offset, tag, j, size;
puts (" Nikon Capture Note:");
sorder = order;
order = 0x4949;
fseek (ifp, 22, SEEK_CUR);
for (offset=22; offset+22 < length; offset += 22+size) {
tag = get4();
fseek (ifp, 14, SEEK_CUR);
size = get4()-4;
printf(" tag=0x%08x, size=%d", tag, size);
for (j=0; j < size; j++)
printf ("%s%02x", j & 31 ? " ":"\n\t", fgetc(ifp));
puts("");
}
order = sorder;
}
void nikon_decrypt (uchar ci, uchar cj, int tag, int i, int size, uchar *buf)
{
static const uchar xlat[2][256] = {
{ 0xc1,0xbf,0x6d,0x0d,0x59,0xc5,0x13,0x9d,0x83,0x61,0x6b,0x4f,0xc7,0x7f,0x3d,0x3d,
0x53,0x59,0xe3,0xc7,0xe9,0x2f,0x95,0xa7,0x95,0x1f,0xdf,0x7f,0x2b,0x29,0xc7,0x0d,
0xdf,0x07,0xef,0x71,0x89,0x3d,0x13,0x3d,0x3b,0x13,0xfb,0x0d,0x89,0xc1,0x65,0x1f,
0xb3,0x0d,0x6b,0x29,0xe3,0xfb,0xef,0xa3,0x6b,0x47,0x7f,0x95,0x35,0xa7,0x47,0x4f,
0xc7,0xf1,0x59,0x95,0x35,0x11,0x29,0x61,0xf1,0x3d,0xb3,0x2b,0x0d,0x43,0x89,0xc1,
0x9d,0x9d,0x89,0x65,0xf1,0xe9,0xdf,0xbf,0x3d,0x7f,0x53,0x97,0xe5,0xe9,0x95,0x17,
0x1d,0x3d,0x8b,0xfb,0xc7,0xe3,0x67,0xa7,0x07,0xf1,0x71,0xa7,0x53,0xb5,0x29,0x89,
0xe5,0x2b,0xa7,0x17,0x29,0xe9,0x4f,0xc5,0x65,0x6d,0x6b,0xef,0x0d,0x89,0x49,0x2f,
0xb3,0x43,0x53,0x65,0x1d,0x49,0xa3,0x13,0x89,0x59,0xef,0x6b,0xef,0x65,0x1d,0x0b,
0x59,0x13,0xe3,0x4f,0x9d,0xb3,0x29,0x43,0x2b,0x07,0x1d,0x95,0x59,0x59,0x47,0xfb,
0xe5,0xe9,0x61,0x47,0x2f,0x35,0x7f,0x17,0x7f,0xef,0x7f,0x95,0x95,0x71,0xd3,0xa3,
0x0b,0x71,0xa3,0xad,0x0b,0x3b,0xb5,0xfb,0xa3,0xbf,0x4f,0x83,0x1d,0xad,0xe9,0x2f,
0x71,0x65,0xa3,0xe5,0x07,0x35,0x3d,0x0d,0xb5,0xe9,0xe5,0x47,0x3b,0x9d,0xef,0x35,
0xa3,0xbf,0xb3,0xdf,0x53,0xd3,0x97,0x53,0x49,0x71,0x07,0x35,0x61,0x71,0x2f,0x43,
0x2f,0x11,0xdf,0x17,0x97,0xfb,0x95,0x3b,0x7f,0x6b,0xd3,0x25,0xbf,0xad,0xc7,0xc5,
0xc5,0xb5,0x8b,0xef,0x2f,0xd3,0x07,0x6b,0x25,0x49,0x95,0x25,0x49,0x6d,0x71,0xc7 },
{ 0xa7,0xbc,0xc9,0xad,0x91,0xdf,0x85,0xe5,0xd4,0x78,0xd5,0x17,0x46,0x7c,0x29,0x4c,
0x4d,0x03,0xe9,0x25,0x68,0x11,0x86,0xb3,0xbd,0xf7,0x6f,0x61,0x22,0xa2,0x26,0x34,
0x2a,0xbe,0x1e,0x46,0x14,0x68,0x9d,0x44,0x18,0xc2,0x40,0xf4,0x7e,0x5f,0x1b,0xad,
0x0b,0x94,0xb6,0x67,0xb4,0x0b,0xe1,0xea,0x95,0x9c,0x66,0xdc,0xe7,0x5d,0x6c,0x05,
0xda,0xd5,0xdf,0x7a,0xef,0xf6,0xdb,0x1f,0x82,0x4c,0xc0,0x68,0x47,0xa1,0xbd,0xee,
0x39,0x50,0x56,0x4a,0xdd,0xdf,0xa5,0xf8,0xc6,0xda,0xca,0x90,0xca,0x01,0x42,0x9d,
0x8b,0x0c,0x73,0x43,0x75,0x05,0x94,0xde,0x24,0xb3,0x80,0x34,0xe5,0x2c,0xdc,0x9b,
0x3f,0xca,0x33,0x45,0xd0,0xdb,0x5f,0xf5,0x52,0xc3,0x21,0xda,0xe2,0x22,0x72,0x6b,
0x3e,0xd0,0x5b,0xa8,0x87,0x8c,0x06,0x5d,0x0f,0xdd,0x09,0x19,0x93,0xd0,0xb9,0xfc,
0x8b,0x0f,0x84,0x60,0x33,0x1c,0x9b,0x45,0xf1,0xf0,0xa3,0x94,0x3a,0x12,0x77,0x33,
0x4d,0x44,0x78,0x28,0x3c,0x9e,0xfd,0x65,0x57,0x16,0x94,0x6b,0xfb,0x59,0xd0,0xc8,
0x22,0x36,0xdb,0xd2,0x63,0x98,0x43,0xa1,0x04,0x87,0x86,0xf7,0xa6,0x26,0xbb,0xd6,
0x59,0x4d,0xbf,0x6a,0x2e,0xaa,0x2b,0xef,0xe6,0x78,0xb6,0x4e,0xe0,0x2f,0xdc,0x7c,
0xbe,0x57,0x19,0x32,0x7e,0x2a,0xd0,0xb8,0xba,0x29,0x00,0x3c,0x52,0x7d,0xa8,0x49,
0x3b,0x2d,0xeb,0x25,0x49,0xfa,0xa3,0xaa,0x39,0xa7,0xc5,0xa7,0x50,0x11,0x36,0xfb,
0xc6,0x67,0x4a,0xf5,0xa5,0x12,0x65,0x7e,0xb0,0xdf,0xaf,0x4e,0xb3,0x61,0x7f,0x2f } };
uchar ck=0x60;
if (strncmp ((char *)buf, "02", 2)) return;
ci = xlat[0][ci];
cj = xlat[1][cj];
printf("Decrypted tag 0x%x:\n%*s", tag, (i & 31)*3, "");
for (; i < size; i++)
printf("%02x%c", buf[i] ^ (cj += ci * ck++), (i & 31) == 31 ? '\n':' ');
if (size & 31) puts("");
}
int parse_tiff_ifd (int base, int level);
void parse_makernote (base)
{
int offset=0, entries, tag, type, count, val, save;
unsigned serial=0, key=0;
uchar buf91[630]="", buf97[608]="", buf98[31]="";
short sorder;
char buf[10];
/*
The MakerNote might have its own TIFF header (possibly with
its own byte-order!), or it might just be a table.
*/
sorder = order;
fread (buf, 1, 10, ifp);
if (!strcmp (buf,"Nikon")) { /* starts with "Nikon\0\2\0\0\0" ? */
base = ftell(ifp);
order = get2(); /* might differ from file-wide byteorder */
val = get2(); /* should be 42 decimal */
offset = get4();
fseek (ifp, offset-8, SEEK_CUR);
} else if (!strncmp (buf,"FUJIFILM",8) ||
!strncmp (buf,"SONY",4) ||
!strcmp (buf,"Panasonic")) {
order = 0x4949;
fseek (ifp, 2, SEEK_CUR);
} else if (!strcmp (buf,"OLYMP") ||
!strcmp (buf,"LEICA") ||
!strcmp (buf,"Ricoh") ||
!strcmp (buf,"EPSON"))
fseek (ifp, -2, SEEK_CUR);
else if (!strcmp (buf,"AOC"))
fseek (ifp, -4, SEEK_CUR);
else
fseek (ifp, -10, SEEK_CUR);
entries = get2();
if (entries > 100) return;
puts(" MakerNote:");
while (entries--) {
save = ftell(ifp);
tag = get2();
type = get2();
count= get4();
tiff_dump (base, tag, type, count, 2);
if (tag == 0x1d)
while ((val = fgetc(ifp)))
serial = serial*10 + (isdigit(val) ? val - '0' : val % 10);
if (tag == 0x91)
fread (buf91, sizeof buf91, 1, ifp);
if (tag == 0x97)
fread (buf97, sizeof buf97, 1, ifp);
if (tag == 0x98)
fread (buf98, sizeof buf98, 1, ifp);
if (tag == 0xa7)
key = fgetc(ifp)^fgetc(ifp)^fgetc(ifp)^fgetc(ifp);
if (!strcmp (buf,"OLYMP") && tag >> 8 == 0x20)
parse_tiff_ifd (base, 3);
if (tag == 0xe01)
parse_nikon_capture_note (count);
if (tag == 0xb028) {
fseek (ifp, get4(), SEEK_SET);
parse_tiff_ifd (base, 3);
}
fseek (ifp, save+12, SEEK_SET);
}
nikon_decrypt (serial, key, 0x91, 4, sizeof buf91, buf91);
if (!strncmp ((char *)buf97, "0205", 4))
nikon_decrypt (serial, key, 0x97, 4, 284, buf97);
else
nikon_decrypt (serial, key, 0x97, 284, sizeof buf97, buf97);
nikon_decrypt (serial, key, 0x98, 4, sizeof buf98, buf98);
order = sorder;
}
void parse_exif(int base)
{
int entries, tag, type, count, save;
puts("EXIF table:");
entries = get2();
while (entries--) {
save = ftell(ifp);
tag = get2();
type = get2();
count= get4();
tiff_dump (base, tag, type, count, 1);
if (tag == 0x927c)
parse_makernote (base);
fseek (ifp, save+12, SEEK_SET);
}
}
void parse_mos(int level);
void sony_decrypt (unsigned *data, int len, int start, int key)
{
static unsigned pad[128], p;
if (start) {
for (p=0; p < 4; p++)
pad[p] = key = key * 48828125 + 1;
pad[3] = pad[3] << 1 | (pad[0]^pad[2]) >> 31;
for (p=4; p < 127; p++)
pad[p] = (pad[p-4]^pad[p-2]) << 1 | (pad[p-3]^pad[p-1]) >> 31;
for (p=0; p < 127; p++)
pad[p] = htonl(pad[p]);
}
while (len--)
*data++ ^= pad[p++ & 127] = pad[(p+1) & 127] ^ pad[(p+65) & 127];
}
int parse_tiff_ifd (int base, int level)
{
int entries, tag, type, count, slen, save, save2, i;
unsigned *buf, sony_offset=0, sony_length=0, sony_key=0;
FILE *sfp;
entries = get2();
if (entries > 1024) return 1;
while (entries--) {
save = ftell(ifp);
tag = get2();
type = get2();
count= get4();
slen = count;
if (slen > 128) slen = 128;
tiff_dump (base, tag, type, count, level);
switch (tag) {
case 0x10f: /* Make tag */
fgets (make, slen, ifp);
break;
case 0x110: /* Model tag */
fgets (model, slen, ifp);
break;
case 33405: /* Model2 tag */
fgets (model2, slen, ifp);
break;
case 0x14a: /* SubIFD tag */
save2 = ftell(ifp);
for (i=0; i < count; i++) {
printf ("SubIFD #%d:\n", i+1);
fseek (ifp, save2 + i*4, SEEK_SET);
fseek (ifp, get4()+base, SEEK_SET);
parse_tiff_ifd (base, level+1);
}
break;
case 29184: sony_offset = get4(); break;
case 29185: sony_length = get4(); break;
case 29217: sony_key = get4(); break;
case 33424:
puts("Kodak private data:");
fseek (ifp, get4()+base, SEEK_SET);
parse_tiff_ifd (base, level+1);
break;
case 34310:
parse_mos(0);
break;
case 34665:
fseek (ifp, get4()+base, SEEK_SET);
parse_exif (base);
break;
case 50706:
is_dng = 1;
break;
case 50740:
if (count != 4 || type != 1) break;
puts("Sony SR2 private IFD:");
fseek (ifp, get4()+base, SEEK_SET);
parse_tiff_ifd (base, level+1);
}
fseek (ifp, save+12, SEEK_SET);
}
if (sony_length && (buf = malloc(sony_length))) {
fseek (ifp, sony_offset, SEEK_SET);
fread (buf, sony_length, 1, ifp);
sony_decrypt (buf, sony_length/4, 1, sony_key);
sfp = ifp;
if ((ifp = tmpfile())) {
fwrite (buf, sony_length, 1, ifp);
fseek (ifp, 0, SEEK_SET);
puts ("Sony SR2 encrypted IFD:");
parse_tiff_ifd (-sony_offset, level);
fclose (ifp);
}
ifp = sfp;
free (buf);
}
return 0;
}
/*
Parse a TIFF file looking for camera model and decompress offsets.
*/
void parse_tiff (int base)
{
int doff, ifd=0;
fseek (ifp, base, SEEK_SET);
order = get2();
if (order != 0x4949 && order != 0x4d4d) return;
get2();
while ((doff = get4())) {
fseek (ifp, doff+base, SEEK_SET);
printf ("IFD #%d:\n", ifd++);
if (parse_tiff_ifd (base, 0)) break;
}
}
void parse_minolta()
{
int data_offset, save, tag, len;
fseek (ifp, 4, SEEK_SET);
data_offset = get4() + 8;
while ((save=ftell(ifp)) < data_offset) {
tag = get4();
len = get4();
printf ("Tag %c%c%c offset %06x length %06x\n",
tag>>16, tag>>8, tag, save, len);
switch (tag) {
case 0x545457: /* TTW */
parse_tiff (ftell(ifp));
}
fseek (ifp, save+len+8, SEEK_SET);
}
}
/*
Parse the CIFF structure.
*/
void parse_ciff (int offset, int length, int level)
{
int tboff, nrecs, i, j, type, len, dlen, roff, aoff=0, save;
char c, name[256];
ushort key[2];
fseek (ifp, offset+length-4, SEEK_SET);
tboff = get4() + offset;
fseek (ifp, tboff, SEEK_SET);
nrecs = get2();
if (nrecs > 100) return;
printf ("%*s%d records:\n", level*2, "", nrecs);
for (i = 0; i < nrecs; i++) {
save = ftell(ifp);
type = get2();
printf ("%*stype=0x%04x", level*2, "", type);
if (type & 0x4000) {
len = 8;
type &= 0x3fff;
} else {
len = get4();
roff = get4();
aoff = offset + roff;
printf (", length=%d, reloff=%d, absoff=%d",
len, roff, aoff);
fseek (ifp, aoff, SEEK_SET);
}
if ((type & 0xe700) == 0)
printf (", data=");
if (type == 0x0032) /* display as words */
type |= 0x1000;
dlen = len < DLEN ? len:DLEN;
switch (type >> 8) {
case 0x28:
case 0x30:
putchar('\n');
parse_ciff (aoff, len, level+1);
fseek (ifp, save+10, SEEK_SET);
continue;
case 0x00: /* byte values */
for (j = 0; j < dlen; j++)
printf ("%c%02x",(j & 31) || dlen < 16 ? ' ':'\n', fgetc(ifp) & 0xff);
break;
case 0x08: /* null-terminated ASCII strings */
putchar('\"');
for (j = 0; j < dlen; j++) {
c = fgetc(ifp);
putchar( isprint(c) ? c:'.');
}
putchar('\"');
break;
case 0x10: /* word values */
key[0] = get2();
fseek (ifp, -2, SEEK_CUR);
if (type == 0x1032 && key[0] == 1040)
key[1] = 17907;
else key[0] = key[1] = 0;
for (j = 0; j < dlen; j+=2)
printf ("%c%5u",(j & 31) || dlen < 16 ? ' ':'\n',
get2() ^ key[(j >> 1) & 1]);
break;
case 0x18: /* dword values */
for (j = 0; j < dlen; j+=4)
printf ("%c%08x",(j & 31) || dlen < 16 ? ' ':'\n', get4());
}
putchar('\n');
fseek (ifp, save+10, SEEK_SET);
if (type == 0x080a) { /* Get the camera name */
fseek (ifp, aoff, SEEK_SET);
fread (name, 256, 1, ifp);
strcpy (make, name);
strcpy (model, name + strlen(make)+1);
}
}
}
int parse_jpeg (int offset)
{
int len, save, hlen;
fseek (ifp, offset, SEEK_SET);
if (fgetc(ifp) != 0xff || fgetc(ifp) != 0xd8) return 0;
while (fgetc(ifp) == 0xff && fgetc(ifp) >> 4 != 0xd) {
order = 0x4d4d;
len = get2() - 2;
save = ftell(ifp);
order = get2();
hlen = get4();
if (get4() == 0x48454150) /* "HEAP" */
parse_ciff (save+hlen, len-hlen, 0);
parse_tiff (save+6);
fseek (ifp, save+len, SEEK_SET);
}
return 1;
}
void parse_riff (int level)
{
unsigned i, size, end, save;
char tag[4], type[4], buf[64];
order = 0x4949;
fread (tag, 4, 1, ifp);
size = get4();
if (isdigit(tag[0])) {
fseek (ifp, size, SEEK_CUR);
return;
}
printf ("%*.4s size %d", level*4+4, tag, size);
if (!memcmp(tag,"RIFF",4) || !memcmp(tag,"LIST",4)) {
end = ftell(ifp) + size;
fread (type, 4, 1, ifp);
printf (" type %.4s:\n", type);
while (ftell(ifp) < end)
parse_riff (level+1);
} else {
save = ftell(ifp);
fread (buf, 1, 40, ifp);
printf (": ");
for (i=0; i < 40 && isprint(buf[i]); i++)
putchar (buf[i]);
putchar ('\n');
fseek (ifp, save+size, SEEK_SET);
}
}
void parse_mos(int level)
{
char data[256];
int i, skip, save;
char *cp;
save = ftell(ifp);
while (1) {
if (get4() != 0x504b5453) break;
get4();
printf ("%*sPKTS ", level, "");
fread (data, 1, 40, ifp);
skip = get4();
printf ("%s %d bytes: ", data, skip);
if (!strcmp(data,"pattern_ratation_angle")) {
printf ("%d\n", get2());
continue;
}
if (!strcmp(data,"icc_camera_to_tone_matrix")) {
for (i=0; i < skip/4; i++)
printf ("%f ", int_to_float(get4()));
putchar('\n');
continue;
}
fread (data, 1, sizeof data, ifp);
fseek (ifp, -sizeof data, SEEK_CUR);
data[sizeof data - 1] = 0;
while ((cp=strchr(data,'\n')))
*cp = ' ';
printf ("%s\n",data);
parse_mos(level+2);
fseek (ifp, skip, SEEK_CUR);
}
fseek (ifp, save, SEEK_SET);
}
void parse_rollei()
{
char line[128], *val;
fseek (ifp, 0, SEEK_SET);
do {
fgets (line, 128, ifp);
fputs (line, stdout);
if ((val = strchr(line,'=')))
*val++ = 0;
else
val = line + strlen(line);
} while (strncmp(line,"EOHD",4));
strcpy (make, "Rollei");
strcpy (model, "d530flex");
}
void get_utf8 (int offset, char *buf, int len)
{
ushort c;
char *cp;
fseek (ifp, offset, SEEK_SET);
for (cp=buf; (c = get2()) && cp+3 < buf+len; ) {
if (c < 0x80)
*cp++ = c;
else if (c < 0x800) {
*cp++ = 0xc0 + (c >> 6);
*cp++ = 0x80 + (c & 0x3f);
} else {
*cp++ = 0xe0 + (c >> 12);
*cp++ = 0x80 + (c >> 6 & 0x3f);
*cp++ = 0x80 + (c & 0x3f);
}
}
*cp = 0;
}
void parse_foveon()
{
int entries, off, len, tag, save, i, j, k, pent, poff[256][2];
char name[128], value[128], camf[0x20000], *pos, *cp, *dp;
unsigned val, key, type, num, ndim, dim[3];
order = 0x4949; /* Little-endian */
fseek (ifp, -4, SEEK_END);
fseek (ifp, get4(), SEEK_SET);
if (get4() != 0x64434553) { /* SECd */
printf ("Bad Section identifier at %6x\n", (int)ftell(ifp)-4);
return;
}
get4();
entries = get4();
while (entries--) {
off = get4();
len = get4();
tag = get4();
save = ftell(ifp);
fseek (ifp, off, SEEK_SET);
printf ("%c%c%c%c at offset %06x, length %06x, ",
tag, tag >> 8, tag >> 16, tag >> 24, off, len);
if (get4() != (0x20434553 | (tag << 24))) {
printf ("Bad Section identifier at %6x\n", off);
goto next;
}
val = get4();
printf ("version %d.%d, ",val >> 16, val & 0xffff);
switch (tag) {
case 0x32414d49: /* IMA2 */
case 0x47414d49: /* IMAG */
printf ("type %d, " , get4());
printf ("format %2d, " , get4());
printf ("columns %4d, " , get4());
printf ("rows %4d, " , get4());
printf ("rowsize %d\n" , get4());
parse_jpeg (off+28);
order = 0x4949;
break;
case 0x464d4143: /* CAMF */
printf ("type %d, ", get4());
get4();
for (i=0; i < 4; i++)
putchar(fgetc(ifp));
val = get4();
printf (" version %d.%d:\n",val >> 16, val & 0xffff);
key = get4();
if ((len -= 28) > 0x20000)
len = 0x20000;
fread (camf, 1, len, ifp);
for (i=0; i < len; i++) {
key = (key * 1597 + 51749) % 244944;
val = key * (INT64) 301593171 >> 24;
camf[i] ^= ((((key << 8) - val) >> 1) + val) >> 17;
}
for (pos=camf; (unsigned) (pos-camf) < len; pos += sget4(pos+8)) {
if (strncmp (pos, "CMb", 3)) {
printf("Bad CAMF tag \"%.4s\"\n", pos);
break;
}
val = sget4(pos+4);
printf (" %4.4s version %d.%d: ", pos, val >> 16, val & 0xffff);
switch (pos[3]) {
case 'M':
cp = pos + sget4(pos+16);
type = sget4(cp);
ndim = sget4(cp+4);
dim[0] = dim[1] = dim[2] = 1;
printf ("%d-dimensonal array %s of type %d:\n Key: (",
ndim, pos+sget4(pos+12), sget4(cp));
dp = pos + sget4(cp+8);
for (i=ndim; i--; ) {
cp += 12;
dim[i] = sget4(cp);
printf ("%s %d%s", pos+sget4(cp+4), dim[i], i ? ", ":")\n");
}
for (i=0; i < dim[2]; i++) {
for (j=0; j < dim[1]; j++) {
printf (" ");
for (k=0; k < dim[0]; k++)
switch (type) {
case 5:
printf ("%7d", *(uchar *)dp++);
break;
case 0:
case 6:
printf ("%7d", (short) sget2(dp));
dp += 2;
break;
case 1:
case 2:
printf (" %d", sget4(dp));
dp += 4;
break;
case 3:
val = sget4(dp);
printf (" %9f", int_to_float(val));
dp += 4;
}
printf ("\n");
}
printf ("\n");
}
break;
case 'P':
val = sget4(pos+16);
num = sget4(pos+val);
printf ("%s, %d parameters:\n", pos+sget4(pos+12), num);
cp = pos+val+8 + num*8;
for (i=0; i < num; i++) {
val += 8;
printf (" %s = %s\n", cp+sget4(pos+val), cp+sget4(pos+val+4));
}
break;
case 'T':
cp = pos + sget4(pos+16);
printf ("%s = %.*s\n", pos+sget4(pos+12), sget4(cp), cp+4);
break;
default:
printf ("\n");
}
}
break;
case 0x504f5250: /* PROP */
printf ("entries %d, ", pent=get4());
printf ("charset %d, ", get4());
get4();
printf ("nchars %d\n", get4());
off += pent*8 + 24;
if (pent > 256) pent=256;
for (i=0; i < pent*2; i++)
poff[0][i] = off + get4()*2;
for (i=0; i < pent; i++) {
get_utf8 (poff[i][0], name, 128);
get_utf8 (poff[i][1], value, 128);
printf (" %s = %s\n", name, value);
if (!strcmp (name,"CAMMANUF"))
strcpy (make, value);
if (!strcmp (name,"CAMMODEL"))
strcpy (model, value);
}
}
next:
fseek (ifp, save, SEEK_SET);
}
}
void parse_fuji (int offset)
{
int entries, tag, len;
fseek (ifp, offset, SEEK_SET);
if (!(len = get4())) return;
printf ("Fuji table at %d:\n",len);
fseek (ifp, len, SEEK_SET);
entries = get4();
if (entries > 255) return;
while (entries--) {
tag = get2();
len = get2();
printf ("Fuji tag=0x%x, len=%d, data =",tag,len);
while (len--)
printf (" %02x",fgetc(ifp));
putchar ('\n');
}
}
void parse_phase_one (int base)
{
unsigned entries, tag, type, len, data, save;
unsigned meta=0, wide=0, high=0, i, j;
char str[256];
fseek (ifp, base, SEEK_SET);
order = get4() & 0xffff;
if (get4() >> 8 != 0x526177) return;
fseek (ifp, base+get4(), SEEK_SET);
entries = get4();
get4();
while (entries--) {
tag = get4();
type = get4();
len = get4();
data = get4();
save = ftell(ifp);
printf ("Phase One tag=0x%x, type=%d, len=%2d, data = 0x%x",
tag, type, len, data);
if (type == 4 && len == 4 && data > 0xfffffff)
printf (" = %f", int_to_float(data));
putchar ('\n');
if (tag == 0x110) meta = base+data;
if (len > 4)
fseek (ifp, base+data, SEEK_SET);
if (type == 1 && len < 256) {
fread (str, 256, 1, ifp);
puts (str);
}
if (tag != 0x21c && type == 4 && len > 4) {
for ( ; len > 0; len -= 4)
printf ("%f ", int_to_float(get4()));
puts ("");
}
fseek (ifp, save, SEEK_SET);
}
strcpy (make, "Phase One");
strcpy (model, "unknown");
if (!meta) return;
fseek (ifp, meta, SEEK_SET);
order = get2();
fseek (ifp, 6, SEEK_CUR);
fseek (ifp, meta+get4(), SEEK_SET);
entries = get4();
get4();
while (entries--) {
tag = get4();
len = get4();
data = get4();
save = ftell(ifp);
printf ("Phase One meta tag=0x%x, len=%2d, offset = 0x%x, data = ",
tag, len, data);
if (!((0x000801f4 >> (tag-0x400)) & 1)) putchar ('\n');
fseek (ifp, meta+data, SEEK_SET);
switch (tag) {
case 0x400:
for (i=0; i < len; i+=2)
printf ("%5u%c", get2(), (i & 6) == 6 || i == len-2 ? '\n':' ');
break;
case 0x401:
for (i=0; i < 16; i+=2)
printf ("%6u%c", get2(), (i & 14) == 14 || i == len-2 ? '\n':' ');
for (; i < len; i+=4)
printf ("%9.6f%c", int_to_float(get4()),
(i & 28) == 12 || i == len-4 ? '\n':' ');
break;
case 0x402:
printf ("%f\n", int_to_float (data));
break;
case 0x404: case 0x405: case 0x406: case 0x407:
fread (str, 256, 1, ifp);
puts (str);
break;
case 0x408: case 0x413:
printf ("%lf\n", get_double());
break;
case 0x40b: case 0x410: case 0x416:
for (i=0; i < len; i+=2)
printf ("%6u%c", get2(), (i & 14) == 14 || i == len-2 ? '\n':' ');
break;
case 0x40f: case 0x418: case 0x419: case 0x41a:
for (i=0; i < 4; i++)
printf ("%02X%c", fgetc(ifp), i == 3 ? '\n':' ');
for (; i < len; i+=4)
printf ("%e%c", int_to_float(get4()), i == len-4 ? '\n':' ');
break;
case 0x412:
for (i=0; i < 36; i+=4) {
printf ("%u ", j=get4());
if (i == 4) wide = j;
if (i == 12) high = j*2;
}
printf ("%u\n", get2());
for (i=0; i < wide*high; i++)
printf ("%9.6f%c", int_to_float(get4()),
i % wide == wide-1 ? '\n':' ');
for (i=0; i < wide*high; i++)
printf ("%5u%c", get2(), i % wide == wide-1 ? '\n':' ');
break;
default:
for (i=0; i < len; i++)
printf ("%02X%c", fgetc(ifp),
(i & 15) == 15 || i == len-1 ? '\n':' ');
}
fseek (ifp, save, SEEK_SET);
}
}
char *memmem (char *haystack, size_t haystacklen,
char *needle, size_t needlelen)
{
char *c;
for (c = haystack; c <= haystack + haystacklen - needlelen; c++)
if (!memcmp (c, needle, needlelen))
return c;
return NULL;
}
/*
Identify which camera created this file, and set global variables
accordingly. Return nonzero if the file cannot be decoded.
*/
void identify()
{
char head[32], *cp;
unsigned hlen, fsize, toff, tlen;
make[0] = model[0] = model2[0] = is_dng = 0;
order = get2();
hlen = get4();
fseek (ifp, 0, SEEK_SET);
fread (head, 1, 32, ifp);
fseek (ifp, 0, SEEK_END);
fsize = ftell(ifp);
if ((cp = memmem (head, 32, "MMMM", 4)) ||
(cp = memmem (head, 32, "IIII", 4))) {
parse_phase_one (cp-head);
if (cp-head) parse_tiff (0);
} else if (order == 0x4949 || order == 0x4d4d) {
if (!memcmp(head+6,"HEAPCCDR",8)) {
parse_ciff (hlen, fsize - hlen, 0);
fseek (ifp, hlen, SEEK_SET);
} else
parse_tiff (0);
} else if (!memcmp (head,"NDF0",4)) {
parse_tiff (12);
} else if (!memcmp (head,"\0MRM",4)) {
parse_minolta();
} else if (!memcmp (head,"FUJIFILM",8)) {
fseek (ifp, 84, SEEK_SET);
toff = get4();
tlen = get4();
parse_fuji (92);
if (toff > 120) parse_fuji (120);
parse_tiff (toff+12);
} else if (!memcmp (head,"RIFF",4)) {
fseek (ifp, 0, SEEK_SET);
parse_riff(0);
} else if (!memcmp (head,"DSC-Image",9))
parse_rollei();
else if (!memcmp (head,"FOVb",4))
parse_foveon();
parse_jpeg(0);
}
int main(int argc, char **argv)
{
int arg;
if (argc == 1)
{
fprintf (stderr,
"\nRaw Photo Parser"
"\nby Dave Coffin, dcoffin a cybercom o net"
"\n\nUsage: %s file1.crw file2.crw ...\n", argv[0]);
return 1;
}
for (arg=1; arg < argc; arg++)
{
fname = argv[arg];
ifp = fopen (fname,"rb");
if (!ifp) {
perror (fname);
continue;
}
printf ("\nParsing %s:\n", fname);
identify();
fclose (ifp);
}
return 0;
}

0
ready Normal file
View File

20
update_dcraw Normal file
View File

@ -0,0 +1,20 @@
#! /bin/sh
# Call this script to update dcraw to latest version.
wget -N http://www.cybercom.net/~dcoffin/dcraw/dcraw.1
wget -N http://www.cybercom.net/~dcoffin/dcraw/parse.c
wget -N http://www.cybercom.net/~dcoffin/dcraw/fujiturn.c
wget -N http://www.cybercom.net/~dcoffin/dcraw/dcwrap
wget -N http://www.cybercom.net/~dcoffin/dcraw/dcraw.c
wget -N http://www.cybercom.net/~dcoffin/dcraw/.badpixels
mv _badpixels badpixels
( URL="http://www.cybercom.net/~dcoffin/dcraw/" ; echo -e "$URL:\n" ; LC_ALL=C lynx -dump "$URL" | sed '1d;3,4d' ) >README
wget http://www.cybercom.net/~dcoffin/dcraw/RCS/dcraw.c,v
rlog dcraw.c >dcraw.log
echo
echo "Please check, whether packaged file list is up to date."
echo "Don't forget to change the version in dcraw.spec." $(head -n 1 dcraw.c,v)
echo "You can look at dcraw.log for the complete change log."
echo "Before submit, please call:"
echo "rm dcraw.c,v dcraw.log"