NEF thumbnail distorted

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Alexis Rombaut
Posts: 3
Joined: 2013-11-28T09:00:44-07:00
Authentication code: 6789

NEF thumbnail distorted

Post by Alexis Rombaut »

We use imagemagick to convert NEF to JPG thumbnails. For a particular D600 Nikon it produces an odd result.
NEF: <on request>
JPG: http://i.imgur.com/GfhGNJj.jpg?1
Note the distortion in the corner, especially in the top right corner

* Command line:

Code: Select all

convert -verbose -limit memory 1073741824 -limit map 1073741824 '../work/c34c29a2548e401a8e2696aaf57c8a01/DSC_6935.NEF' -background white -flatten -thumbnail 2000x2000 -quality 80 -auto-orient -profile dat/sRGB_v4_ICC_preference.icc -strip -colorspace sRGB ../work/c34c29a2548e401a8e2696aaf57c8a01/30.jpg
* Version:

Code: Select all

ImageMagick 6.7.7-10 2013-09-10 Q16 http://www.imagemagick.org (Ubuntu 13.10)
* Verbose:

Code: Select all

"ufraw-batch" --silent --create-id=also --out-type=png --out-depth=16 "--output=/tmp/magick-_zvRIwji.png" "/tmp/magick-js1b0Qkb"
 Found a generic profile, type exif
/tmp/magick-_zvRIwji.png PNG 6049x4052 6049x4052+0+0 16-bit DirectClass 108.6MB 2.420u 0:02.410
../work/c34c29a2548e401a8e2696aaf57c8a01/DSC_6935.NEF=>/tmp/magick-_zvRIwji.png NEF 6049x4052 6049x4052+0+0 16-bit DirectClass 108.6MB 0.020u 0:00.019
dat/sRGB_v4_ICC_preference.icc ICC 1x1 1x1+0+0 16-bit DirectClass 61KB 0.000u 0:00.000
../work/c34c29a2548e401a8e2696aaf57c8a01/DSC_6935.NEF=>../work/c34c29a2548e401a8e2696aaf57c8a01/30.jpg NEF 6049x4052=>2000x1340 8-bit DirectClass 147KB 2.980u 0:00.480
* Metadata:

Code: Select all

ExifTool Version Number         : 8.74
File Name                       : DSC_6935.NEF
Directory                       : /home/vsftp/src
File Size                       : 28 MB
File Modification Date/Time     : 2013:11:28 10:44:46+01:00
File Permissions                : rw-r--r--
File Type                       : NEF
MIME Type                       : image/x-nikon-nef
Exif Byte Order                 : Big-endian (Motorola, MM)
Make                            : NIKON CORPORATION
Camera Model Name               : NIKON D600
Orientation                     : Horizontal (normal)
Software                        : Ver.1.01
Modify Date                     : 2013:11:22 12:12:30
Artist                          : 
Jpg From Raw Start              : 1059328
Jpg From Raw Length             : 2166375
Y Cb Cr Positioning             : Co-sited
Image Width                     : 6080
Image Height                    : 4028
Bits Per Sample                 : 14
Compression                     : Nikon NEF Compressed
Photometric Interpretation      : Color Filter Array
Strip Offsets                   : 3226112
Samples Per Pixel               : 1
Rows Per Strip                  : 4028
Strip Byte Counts               : 26188670
X Resolution                    : 300
Y Resolution                    : 300
Planar Configuration            : Chunky
Resolution Unit                 : inches
CFA Repeat Pattern Dim          : 2 2
CFA Pattern 2                   : 0 1 1 2
Subfile Type                    : Reduced-resolution image
Other Image Start               : 186880
Other Image Length              : 871960
Reference Black White           : 0 255 0 255 0 255
Copyright                       : 
Exposure Time                   : 1/125
F Number                        : 11.0
Exposure Program                : Shutter speed priority AE
ISO                             : 400
Sensitivity Type                : Recommended Exposure Index
Create Date                     : 2013:11:22 12:12:30
Exposure Compensation           : -1/2
Max Aperture Value              : 2.8
Metering Mode                   : Multi-segment
Light Source                    : Unknown
Flash                           : Off, Did not fire
Focal Length                    : 14.0 mm
Maker Note Version              : 2.10
Quality                         : RAW
White Balance                   : Auto2
Focus Mode                      : Manual
Flash Setting                   : 
Flash Type                      : 
White Balance Fine Tune         : 0 0
WB RB Levels                    : 1.984375 1.25390625 1 1
Program Shift                   : 0
Exposure Difference             : 0
Preview Image Start             : 25432
Preview Image Length            : 103179
Flash Exposure Compensation     : 0
ISO Setting                     : 400
External Flash Exposure Comp    : 0
Flash Exposure Bracket Value    : 0.0
Exposure Bracket Value          : 0
Crop Hi Speed                   : Off (6080x4028 cropped to 6080x4028 at pixel 0,0)
Exposure Tuning                 : 0
Serial Number                   : 6090362
Color Space                     : sRGB
VR Info Version                 : 0100
Vibration Reduction             : Off
Active D-Lighting               : Auto
Picture Control Version         : 0100
Picture Control Name            : Standard
Picture Control Base            : Standard
Picture Control Adjust          : Default Settings
Picture Control Quick Adjust    : Normal
Brightness                      : Normal
Hue Adjustment                  : None
Filter Effect                   : n/a
Toning Effect                   : n/a
Toning Saturation               : n/a
Timezone                        : +01:00
Daylight Savings                : Yes
Date Display Format             : D/M/Y
ISO Expansion                   : Off
ISO2                            : 400
ISO Expansion 2                 : Off
Vignette Control                : Normal
Auto Distortion Control         : Off
Lens Type                       : D
Lens                            : 14mm f/2.8
Flash Mode                      : Did Not Fire
Shooting Mode                   : Continuous, Auto ISO
Contrast Curve                  : (Binary data 578 bytes, use -b option to extract)
Shot Info Version               : 0225
Firmware Version                : 1.01a
NEF Compression                 : Lossless
Noise Reduction                 : Off
NEF Linearization Table         : (Binary data 46 bytes, use -b option to extract)
Color Balance Unknown           : 0217[...]
Lens Data Version               : 0204
Exit Pupil Position             : 78.8 mm
AF Aperture                     : 2.8
Focus Position                  : 0x01
Focus Distance                  : 3.98 m
Lens ID Number                  : 107
Lens F Stops                    : 6.00
Min Focal Length                : 14.1 mm
Max Focal Length                : 14.1 mm
Max Aperture At Min Focal       : 2.8
Max Aperture At Max Focal       : 2.8
MCU Version                     : 113
Effective Max Aperture          : 2.8
Raw Image Center                : 3040 2014
Retouch History                 : None
Shutter Count                   : 6989
Flash Info Version              : 0105
Vari Program                    : 
Multi Exposure Version          : 0100
Multi Exposure Mode             : Off
Multi Exposure Shots            : 0
Multi Exposure Auto Gain        : Off
High ISO Noise Reduction        : Normal
Power Up Time                   : 2013:11:21 15:03:02
AF Info 2 Version               : 0100
Contrast Detect AF              : Off
AF Area Mode                    : Single Area
Phase Detect AF                 : Off
Primary AF Point                : (none)
AF Points Used                  : (none)
Contrast Detect AF In Focus     : No
File Info Version               : 0100
Directory Number                : 100
File Number                     : 6935
AF Fine Tune                    : On (1)
AF Fine Tune Index              : n/a
AF Fine Tune Adj                : +3
User Comment                    : 
Sub Sec Time                    : 90
Sub Sec Time Original           : 90
Sub Sec Time Digitized          : 90
Sensing Method                  : One-chip color area
File Source                     : Digital Camera
Scene Type                      : Directly photographed
Custom Rendered                 : Normal
Exposure Mode                   : Auto
Digital Zoom Ratio              : 1
Focal Length In 35mm Format     : 14 mm
Scene Capture Type              : Standard
Gain Control                    : Low gain up
Contrast                        : Normal
Saturation                      : Normal
Sharpness                       : Normal
Subject Distance Range          : Unknown
GPS Version ID                  : 2.3.0.0
Date/Time Original              : 2013:11:22 12:12:30
TIFF-EP Standard ID             : 1 0 0 0
Aperture                        : 11.0
Auto Focus                      : Off
Blue Balance                    : 1.253906
CFA Pattern                     : [Red,Green][Green,Blue]
Image Size                      : 6080x4028
Jpg From Raw                    : (Binary data 2166375 bytes, use -b option to extract)
Lens ID                         : AF Nikkor ED 14mm f/2.8D
Lens                            : 14mm f/2.8 D
Other Image                     : (Binary data 871960 bytes, use -b option to extract)
Preview Image                   : (Binary data 103179 bytes, use -b option to extract)
Red Balance                     : 1.984375
Scale Factor To 35 mm Equivalent: 1.0
Shutter Speed                   : 1/125
Create Date                     : 2013:11:22 12:12:30.90
Date/Time Original              : 2013:11:22 12:12:30.90
Modify Date                     : 2013:11:22 12:12:30.90
Circle Of Confusion             : 0.030 mm
Depth Of Field                  : inf (0.52 m - inf)
Field Of View                   : 104.1 deg (10.20 m)
Focal Length                    : 14.0 mm (35 mm equivalent: 14.0 mm)
Hyperfocal Distance             : 0.59 m
Light Value                     : 11.9
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: NEF thumbnail distorted

Post by magick »

Post a URL to the original NEF image, we need to download and inspect it before we can comment.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: NEF thumbnail distorted

Post by snibgo »

I can't be sure without loking at the NEF and possibly experiments with the camera and lens, but this could be an artefact of the very wide-angle lens (14mm) on the FX sensor. Light hits the sensor at an extreme angle, and internal camera hardware can cast a shadow on the edge of the sensor.

According to http://imaging.nikon.com/lineup/dslr/d600/spec.htm the advertised image size of the D600 is "6,016 x 4,016". The sensor is actually larger than this and IM's convert (via its delegate) can include extra pixels. Your metadata reports 6080x4028.

If this is the situation, the trick is to crop the image to the manufacturer's limits before processing further.
snibgo's IM pages: im.snibgo.com
Alexis Rombaut
Posts: 3
Joined: 2013-11-28T09:00:44-07:00
Authentication code: 6789

Re: NEF thumbnail distorted

Post by Alexis Rombaut »

Thank you for your swift replies.

We found the cause of problem was indeed the very wide-angle lens. The delegate ufraw-batch which IM used for NEF has a compile option --with-lensfun which tries correct lensing effects. On debian the maintainer for the ufraw package has enabled this option. We now have compiled our own ufraw and modified delegates.xml. It now produces a correct picture.

The page on ufraw about lensfun literally states:
For distributed packages, it is not recommended to enable lensfun, since most users would not be aware of the problems involved in using this feature.
Hence I think the Debian/Ubuntu maintainer of ufraw is in error here. However, indirectly it also affects IM. There is no command line option to disable this, apart from custom compilation.
Post Reply