Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
While converting Nikon RAW format .NEF files (taken with D40) to PNG with ImageMagick, I get PNG files that are roughly 6 times larger than the original "raw" images. That doesn't make any sense to me. The camera lists the mode as .NEF (RAW) and does not specify lossy/lossless or compressed/uncompressed. Theoretically lossless compression (PNG) should be smaller than RAW format images, unless I'm missing something.
I've also tried using ufraw-batch to convert .NEF to .PPM. I then convert PPM to PNG and get more reasonable file sizes. However, they are still 1-2 MB larger than the original raw .NEF files. Does anyone have any insight into why this is occurring?
syntax wrote:While converting Nikon RAW format .NEF files (taken with D40) to PNG with ImageMagick, I get PNG files that are roughly 6 times larger than the original "raw" images. That doesn't make any sense to me. The camera lists the mode as .NEF (RAW) and does not specify lossy/lossless or compressed/uncompressed. Theoretically lossless compression (PNG) should be smaller than RAW format images, unless I'm missing something. ... Does anyone have any insight into why this is occurring?
Wikipedia (see http://en.wikipedia.org/wiki/Raw_image_format) says "When converting from the four sensor 2x2 Bayer matrix raw form into single RGB pixels the original 4x12 (or 14) bit data is converted to 4x3x8 bit"
That doubles it. If you happen to write 16-bit PNG files, that doubles it again. You could try using the "-depth 8" option to avoid the second doubling (which is the same as what happens when you convert to the intermediate PPM format).
I'm also having the same problem. That explains a few things. But I'm unsure about the remaining 2x increase is size. I converted a 11MB NEF to PNG and to my surprise the size became approx. 60MB.. What is causing this?
PNG doesn't give good compression for photographs. It's actually quite poor for photos.
Another possible factor: NEF files can be compressed or not, and the compression can be lossy or not. A lossy NEF file will certainly be smaller than a PNG made from it.
I use 16-bit tiff files with zip compression, and these are generally about 4x the size of the NEF files. I did a load of tests to determine the best lossless compression, and found that zip tiff was the best.
How can I know whether a NEF is lossy or not? And I wanted a loseless compression from NEF and thats the reason I converted it into PNG. Yep I understood with whatever that you were trying to tell. PNG will be more if you choose a 16 bit depth from a 8 bit NEF, but that should only double the size as far as I understood. What it is causing to go up 6 times than NEF?
I got your point. But I'm not trying to apply compression techniques on images. I'm just curious to know why the size is increasing here. As you told earlier NEF is loseless and PNG is loseless too. And as per expectation the Raw image should have more details than any image formats(PNG,GIF,JEPG,whatever) can possibly have. But why PNG files are more larger than NEF?
The project which I'm doing needs to prove that PNG, JPEG, WEBP are smaller than Raw image. But I'm stuck here on not sure what to submit in report!!
PNG and NEF may be lossless, they probably use different lossless compression algorithms and likely the NEF compression is larger than the PNG compression, so PNG files are larger, since they are not compressed as much. Just my guess!
see http://www.coolutils.com/Formats/NEF. Perhaps you have 12-14 bit data, but when converted to PNG it becomes 16-bits if on Q16 IM. Also possibly there are some meta data in the NEF that is compressed as well and not compressed in the PNG result.
The D40 Nikon is a 6MP camera. Your NEF file is 5.4Mbytes, which is less than 8 bits per pixel so your "raw"
image is actually compressed. Converting a lossy image to lossless is a losing proposition. You are better off
converting to high-resolution JPEG instead.
Convert to JPEG and you will lose data. (a) JPEG is only 8-bit so you lose nearly half the bits. (b) JPEG is lossy. For low quality, it is very lossy, but needs not much disk space. You can experiment with different "-quality" settings. Very low quality will be smaller than NEF.
I don't see the point of capturing a NEF file and simply converting it to JPEG. Why not tell the camera to save it as JPEG?
I was just experimenting In conversion from RAW format to jpeg,png and webp. So now only png is greater among the three. I just want to find out the reasons!!
So as PNG will be affected by Bayers filters which causes the mapping of 2 RGBG to a single RGB. Why its not doing the same in JPEG and WEBP?