Page 1 of 1

Samsung's raw format (SRW)

Posted: 2011-04-04T13:01:20-07:00
by SvenWehner
Dear ImageMagick developers,

I was wondering, if you intend to implement a coder for Samsung's (rather new) SRW file format.
The format seems to be a "Samsungnized" TIFF, used for raw images. (See: http://metadatamadness.blogspot.com/201 ... g-srw.html and http://metadatamadness.blogspot.com/201 ... tards.html)

I have a Samsung WB2000 camera, with Firmware "FM1_010191".

At the moment ImageMagick's "identify" reports:

Code: Select all

identify SAM_0780.SRW
identify SAM_0780.SRW identify: SAM_0780.SRW: invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/704.
identify: SAM_0780.SRW: TIFF directory is missing required "ImageLength" field. `MissingRequired' @ error/tiff.c/TIFFErrors/494.
Exiv2 version 0.21 is able to read the metadata:

Code: Select all

exiv2 print SAM_0780.SRW
File name       : SAM_0780.SRW
File size       : 23957219 Bytes
MIME type       : image/tiff
Image size      : 3728 x 2781
Camera make     : SAMSUNG
Camera model    : WB2000 
Image timestamp : 2011:03:07 12:31:20
Image number    : 
Exposure time   : 1/350 s
Aperture        : F4.3
Exposure bias   : 0 EV
Flash           : No flash
Flash bias      : 
Focal length    : (0/0) (35 mm equivalent: 28.0 mm)
Subject distance: 
ISO speed       : 80
Exposure mode   : Auto
Metering mode   : Multi-segment
Macro mode      : 
Image quality   : 
Exif Resolution : 3728 x 2781
White balance   : Auto
Thumbnail       : None
Copyright       : 
Exif comment    :
And even more verbose:

Code: Select all

exiv2 print SAM_0780.SRW -ph
0x010f Image        Make                        Ascii       8   8
  0000  53 41 4d 53 55 4e 47 00                          SAMSUNG.

0x0110 Image        Model                       Ascii       8   8
  0000  57 42 32 30 30 30 20 00                          WB2000 .

0x0112 Image        Orientation                 Short       1   2
  0000  00 01                                            ..

0x0132 Image        DateTime                    Ascii      20  20
  0000  32 30 31 31 3a 30 33 3a 30 37 20 31 32 3a 33 31  2011:03:07 12:31
  0010  3a 32 30 00                                      :20.

0x8769 Image        ExifTag                     Long        1   4
  0000  00 00 00 82                                      ....

0x829a Photo        ExposureTime                Rational    1   8
  0000  00 00 00 01 00 00 01 5e                          .......^

0x829d Photo        FNumber                     Rational    1   8
  0000  00 00 00 2b 00 00 00 0a                          ...+....

0x8822 Photo        ExposureProgram             Short       1   2
  0000  00 02                                            ..

0x8827 Photo        ISOSpeedRatings             Short       1   2
  0000  00 50                                            .P

0x9000 Photo        ExifVersion                 Undefined   4   4
  0000  30 32 32 31                                      0221

0x9003 Photo        DateTimeOriginal            Ascii      20  20
  0000  32 30 31 31 3a 30 33 3a 30 37 20 31 32 3a 33 31  2011:03:07 12:31
  0010  3a 32 30 00                                      :20.

0x9204 Photo        ExposureBiasValue           SRational   1   8
  0000  00 00 00 00 00 00 00 0a                          ........

0x9207 Photo        MeteringMode                Short       1   2
  0000  00 05                                            ..

0x9208 Photo        LightSource                 Short       1   2
  0000  00 00                                            ..

0x9209 Photo        Flash                       Short       1   2
  0000  00 00                                            ..

0x920a Photo        FocalLength                 Rational    1   8
  0000  00 00 00 00 00 00 00 00                          ........

0x927c Photo        MakerNote                   Undefined 168558 168558
(Binary value suppressed)
0x0001 MakerNote    Offset                      Long        1   4
  0000  00 00 01 d8                                      ....

0x0002 MakerNote    ByteOrder                   Ascii       3   3
  0000  4d 4d 00                                         MM.

0x0001 Samsung2     Version                     Undefined   4   4
  0000  30 31 30 30                                      0100

0x0035 Samsung2     Preview                     Long        1   4
  0000  00 00 45 1c                                      ..E.

0x00fe SamsungPreview NewSubfileType              Long        1   4
  0000  00 00 00 00                                      ....

0x011a SamsungPreview XResolution                 Rational    1   8
  0000  17 18 19 1a 26 27 28 29                          ....&'()

0x011b SamsungPreview YResolution                 Rational    1   8
  0000  2a 35 36 37 38 39 3a 43                          *56789:C

0x0128 SamsungPreview ResolutionUnit              Short       1   2
  0000  00 02                                            ..

0x0201 SamsungPreview JPEGInterchangeFormat       Long        1   4
  0000  00 00 45 86                                      ..E.

0x0202 SamsungPreview JPEGInterchangeFormatLength Long        1   4
  0000  00 02 4c e8                                      ..L.

0x0213 SamsungPreview YCbCrPositioning            Short       1   2
  0000  00 02                                            ..

0xa001 Samsung2     FirmwareName                Ascii      30  30
  0000  46 4d 31 5f 30 31 30 31 39 31 00 ff a0 7e f9 ff  FM1_010191...~..
  0010  ff ff ff ff c4 00 00 00 00 00 00 00 80 00        ..............

0xa003 Samsung2     LensType                    Short       1   2
  0000  00 00                                            ..

0xa010 Samsung2     SensorAreas                 Long        8  32
  0000  00 00 00 00 00 00 00 00 00 00 0e 90 00 00 0a dc  ................
  0010  00 00 00 24 00 00 00 16 00 00 0e 64 00 00 0a c6  ...$.......d....

0xa013 Samsung2     ExposureBiasValue           SRational   1   8
  0000  00 00 00 00 00 00 00 0a                          ........

0xa014 Samsung2     ISO                         Long        1   4
  0000  00 00 00 50                                      ...P

0xa018 Samsung2     ExposureTime                Rational    1   8
  0000  00 00 00 01 00 00 01 5e                          .......^

0xa019 Samsung2     FNumber                     Rational    1   8
  0000  00 00 00 2b 00 00 00 0a                          ...+....

0xa01a Samsung2     FocalLengthIn35mmFormat     Long        1   4
  0000  00 00 00 1c                                      ....

0xa021 Samsung2     WB_RGGBLevels               Long        4  16
  0000  00 00 18 b7 00 00 10 c8 00 00 13 61 00 00 1d 2c  ...........a...,

0xa001 Photo        ColorSpace                  Short       1   2
  0000  00 01                                            ..

0xa002 Photo        PixelXDimension             Long        1   4
  0000  00 00 0e 40                                      ...@

0xa003 Photo        PixelYDimension             Long        1   4
  0000  00 00 0a b0                                      ....

0xa402 Photo        ExposureMode                Short       1   2
  0000  00 02                                            ..

0xa403 Photo        WhiteBalance                Short       1   2
  0000  00 00                                            ..

0xa404 Photo        DigitalZoomRatio            Rational    1   8
  0000  00 00 00 0a 00 00 00 0a                          ........

0xa405 Photo        FocalLengthIn35mmFilm       Short       1   2
  0000  00 1c                                            ..

0xa406 Photo        SceneCaptureType            Short       1   2
  0000  00 00                                            ..

0xa408 Photo        Contrast                    Short       1   2
  0000  00 00                                            ..

0xa409 Photo        Saturation                  Short       1   2
  0000  00 00                                            ..

0xa40a Photo        Sharpness                   Short       1   2
  0000  00 00                                            ..

0x014a Image        SubIFDs                     Long        2   8
  0000  00 02 ca a3 00 02 cb 0d                          ........

0x00fe SubImage1    NewSubfileType              Long        1   4
  0000  00 00 00 00                                      ....

0x011a SubImage1    XResolution                 Rational    1   8
  0000  00 00 00 48 00 00 00 01                          ...H....

0x011b SubImage1    YResolution                 Rational    1   8
  0000  00 00 00 48 00 00 00 01                          ...H....

0x0128 SubImage1    ResolutionUnit              Short       1   2
  0000  00 02                                            ..

0x0201 SubImage1    JPEGInterchangeFormat       Long        1   4
  0000  00 02 cb 97                                      ....

0x0202 SubImage1    JPEGInterchangeFormatLength Long        1   4
  0000  00 2e 5e ac                                      ..^.

0x0213 SubImage1    YCbCrPositioning            Short       1   2
  0000  00 02                                            ..

0x00fe SubImage2    NewSubfileType              Long        1   4
  0000  00 00 00 00                                      ....

0x0100 SubImage2    ImageWidth                  Long        1   4
  0000  00 00 0e 90                                      ....

0x0101 SubImage2    ImageLength                 Long        1   4
  0000  00 00 0a dd                                      ....

0x0102 SubImage2    BitsPerSample               Short       1   2
  0000  00 0e                                            ..

0x0103 SubImage2    Compression                 Long        1   4
  0000  00 00 80 01                                      ....

0x0111 SubImage2    StripOffsets                Long        1   4
  0000  00 31 2a 43                                      .1*C

0x0115 SubImage2    SamplesPerPixel             Short       1   2
  0000  00 03                                            ..

0x0116 SubImage2    RowsPerStrip                Long        1   4
  0000  00 00 0a dd                                      ....

0x0117 SubImage2    StripByteCounts             Long        1   4
  0000  01 3c 64 a0                                      .<d.

0x828d SubImage2    CFARepeatPatternDim         Short       2   4
  0000  00 02 00 02                                      ....

0x828e SubImage2    CFAPattern                  Byte        4   4
  0000  00 01 01 02                                      ....

0x014a Thumbnail    SubIFDs                     Long        1   4
  0000  00 02 94 58                                      ...X

0x00fe SubThumb1    NewSubfileType              Long        1   4
  0000  00 00 00 00                                      ....

0x011a SubThumb1    XResolution                 Rational    1   8
  0000  00 00 00 48 00 00 00 01                          ...H....

0x011b SubThumb1    YResolution                 Rational    1   8
  0000  00 00 00 48 00 00 00 01                          ...H....

0x0128 SubThumb1    ResolutionUnit              Short       1   2
  0000  00 02                                            ..

0x0201 SubThumb1    JPEGInterchangeFormat       Long        1   4
  0000  00 02 94 c2                                      ....

0x0202 SubThumb1    JPEGInterchangeFormatLength Long        1   4
  0000  00 00 35 e1                                      ..5.

0x0213 SubThumb1    YCbCrPositioning            Short       1   2
  0000  00 02                                            ..
And a current version of dcraw is also able to convert the file:

Code: Select all

dcraw -c SAM_0780.SRW | cjpeg > SAM_0780.SRW.jpeg
(Well, this produces a jpeg version of the SRW file…)

If you need some example images, please let me know, and I will provide you some (they are quite large: about 30 MB per image).


Sincerly Yours,
Sven

Re: Samsung's raw format (SRW)

Posted: 2011-04-04T13:27:18-07:00
by magick
Post a URL to 2-5 images in the SRW format. We need to download them and inspect them before we can comment about support. Thanks.

Re: Samsung's raw format (SRW)

Posted: 2011-04-04T16:44:17-07:00
by SvenWehner
Here are three photos I took (with my Samsung WB2000) some weeks ago: (total: 85 MB)

Additionally there are some other images: http://www.photographyblog.com/reviews/ ... le_images/ (made with a Samsung NX10)


Yours,
Sven

Re: Samsung's raw format (SRW)

Posted: 2011-04-04T17:27:02-07:00
by magick
Try this command:
  • convert dng:SAM_0585.SRW SAM_0585.jpg

Re: Samsung's raw format (SRW)

Posted: 2011-04-04T18:40:44-07:00
by SvenWehner
(I played around with the latest versions of software libraries, and found out, that the problem was an outdated ufraw version. 0.18 does work. I just post this for anybody who might run into the same problem…)

With version 6.6.5.6 (currently the stable release on Gentoo) I receive this error:

Code: Select all

convert dng:SAM_0585.SRW SAM_0585.SRW.png
convert: delegate failed `"/usr/bin/ufraw-batch" --silent --wb=camera --black-point=auto --exposure=auto --create-id=also --out-type=png --out-depth=16 "--output=%u.png" "%i"' @ error/delegate.c/InvokeDelegate/1061.
convert: unable to open image `/tmp/magick-XXKggsif.ppm':  @ error/blob.c/OpenBlob/2584.
convert: missing an image filename `SAM_0585.SRW.png' @ error/convert.c/ConvertImageCommand/2949.
And if I run ufraw-batch myself (without "--silent"):

Code: Select all

ufraw-batch --wb=camera --black-point=auto --exposure=auto --create-id=also --out-type=png --out-depth=16 --output="/tmp/abc.png" SAM_0585.SRW 
ufraw-batch: SAM_0585.SRW: Corrupt data near 0x44750e

I updated to version 6.6.8.5 (latest unstable release on Gentoo), and received the same error.

The trick seems to be the update of ufraw to atleast version 0.17 (the latest Gentoo version).
So, now I receive a converted image, but the colors are… interesting.

And then I tried ufraw 0.18, which is based on DCRaw 9.06. And finally, I received valid output.


So, thanks!

But the error, about an invalid TIFF directory, is still there, when I don't use "dng:":

Code: Select all

convert SAM_0901.SRW SAM_0901.SRW.jpg
convert: SAM_0901.SRW: invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/706.
convert: SAM_0901.SRW: TIFF directory is missing required "ImageLength" field. `MissingRequired' @ error/tiff.c/TIFFErrors/496.
convert: missing an image filename `SAM_0901.SRW.jpg' @ error/convert.c/ConvertImageCommand/2974.
I'm not that sure, what you are relying on to decide which coder to use (the "file" command reports "TIFF image data, big-endian"), but could you make the dng coder to open SRW files as well? Is the "RegisterDNGImage()" method in "coders/dng.c" responsible for this?


Yours,
Sven

Re: Samsung's raw format (SRW)

Posted: 2011-04-04T18:51:08-07:00
by magick
There is no easy way to distinquish SRW files from TIFF. As you recommended, see http://metadatamadness.blogspot.com/201 ... g-srw.html. We could possibly key off the file extension (.srw) but that's considered a lower priority over the internal magic string (which says the image is TIFF).