11 Replies Latest reply on Oct 3, 2016 4:07 PM by JimHess

    Editing a DNG file and saving it again as DNG using Photoshop

    psurquidi Level 1

      Hi everyone,

       

      I have a set of .dng raw images which I would like to edit using Photoshop and save back out as .dng files.  It sounds like a very simple task, but I have been struggling with this for half a day.

       

      To give a concrete example, I have two dng images from the same camera. I want to copy an object from one image and paste it to the other, and then save out the output as a .dng file.  This should take me like 2 minutes in Photoshop, right?

      Well, when I open the files, it first brings up the Adobe Camera Raw tool, but this only lets me do very basic edits (I can't figure out how to copy an object from one image to another, let alone perform the necessary edits to blend them seamlessly.).

       

      So I click "Open Image" to get them into Photoshop, where I can do all of my necessary edits (copy and paste, brushes, etc.).  However, after I am finished and I try to save my edits, Photoshop only lets me save the output in .psd (along with other formats) but not dng.  I need to save it back out as .dng, as the next program in our workflow pipeline requires .dng files as input.  So how do I do this simple task?


      Why can't I save my resulting image back out as a .dng file?  I tried saving as .psd and then using Adobe DNG converter to turn it into a dng, but it doesn't seem to be able to do that.  I also tried saving as Photoshop RAW, but for some reason the converter can't convert from Photoshop RAW to DNG.  It doesn't make any sense to me.


      I know that Photoshop knows my camera parameters because it was able to read the original dng files properly in the first place.  So why can't I read in the .dng image make some edits and then save it?  How are people editing dng files?


      Thanks for your help.




       

        • 1. Re: Editing a DNG file and saving it again as DNG using Photoshop
          JimHess Adobe Community Professional & MVP

          DNG files contain raw image data. Photoshop is not capable of editing raw image data nor saving a file with raw image data. By the time the DNG file is open in Photoshop is no longer raw data. Camera Raw converts it to a RGB image file, and that is what is opened in Photoshop. When the Photoshop editing is completed, that file has to be saved in a different file format such as PSD, TIF, JPEG, etc.

           

          Also, there is no way to turn an image back into raw image data after it has been edited in Photoshop. It would be as difficult as uncooking an egg.

          • 2. Re: Editing a DNG file and saving it again as DNG using Photoshop
            psurquidi Level 1

            Also, there is no way to turn an image back into raw image data after it has been edited in Photoshop. It would be as difficult as uncooking an egg.

             

            I understand that this is difficult if I am doing arbitrary image editing operations, since those operations may not be properly defined in the RAW space.  But in this case I am cloning pixels from one .dng image to another.  Shouldn't this be possible?

             

            For example, assume we have 2 dng images and we want to take the left half of one and paste it in the same position over the other.  I am not familiar with the dng spec, but at some level it should encode the values at each pixel (perhaps with the appropriate camera curve).  So I just simply want to overwrite the values of one .dng image with values at the same pixels of the other, and since it's the same camera with the same settings used for both this should be possible, right?  In the worst case, I could write a program based on the DNG spec that parses the two dng files, overwrites the necessary pixel information simply using the second image's data, and then writes the dng back out.  But this seems like a complicated way to do something that there should be an Adobe tool to do.

             

            Perhaps it would help if I tell you exactly why I need this for.  We are capturing raw video using the Blackmagic Cinema Camera which outputs a directory full of 2.5k dng images for each take.  We were doing a take of a scene using a tripod, but an otherwise great take was ruined because at one point a crew member poked their head into frame.   So I want to use information from the other dng frames to overwrite this portion of this image to hide this problem.  

             

            If these were regular images (.jpg, .tif, .exr) it would take us no time in Photoshop to use the information from the other "good" frames to fix this problem seamlessly.  However, we would like to keep everything in dng format so that I can then read everything into DaVinci Resolve for color grading correctly.   Any idea on how I can do this, if I can't use Photoshop?

             

            Thank you in advance for your help!

            • 3. Re: Editing a DNG file and saving it again as DNG using Photoshop
              ssprengel Adobe Community Professional & MVP

              No, PS doesn’t edit 1-color-per-pixel raw data, it edits 3-colors-per-pixel-plus-alpha-channel data.

              • 4. Re: Editing a DNG file and saving it again as DNG using Photoshop
                JimHess Adobe Community Professional & MVP

                As I mentioned in my first response, Photoshop cannot edit raw image data. That is why there has to be a Camera Raw plug-in. That plug-in allows you to make adjustments to the raw image data before it it is opened in Photoshop. When you click Open in Camera Raw the image is converted into an RGB format that Photoshop can manage. You are no longer working with the raw data from the DNG file. Photoshop cannot edit or save raw image data. That is why you haven't been able to figure out how to do it. It's because it can't be done.

                • 5. Re: Editing a DNG file and saving it again as DNG using Photoshop
                  psurquidi Level 1

                  So if Photoshop can't edit RAW data, is there a program that can?  Or do we need to write our own?  Like I said, all we want to do is copy the RAW values from pixels in one image to the pixels in the other.  I am not familiar with the DNG spec, but I assume that in some part of the file there is an array of pixels that lists the RAW values at every pixel (not RGB).  All we need to do is copy the values from some pixels to others.  In the general sense, we would have to be careful because of demosaicing (I assume that the RAW information in the DNG is BEFORE demosaicing) but because the information is coming from the same pixels in other images they have the same Bayer pattern and so we can just copy and paste. 

                   

                  Is there a program that will do this?  If not, I don't understand why not since it would seem to be useful.  You seem to be saying that this is impossible but I do not understand WHY based on my limited understanding of DNG.  (Of course, I am not talking about general image editing - that is obviously not possible in RAW, but rather cloning pixel values).

                   

                  Thanks!

                  • 6. Re: Editing a DNG file and saving it again as DNG using Photoshop
                    ssprengel Adobe Community Professional & MVP

                    There are programs that can convert the Bayer array (pre-demosaicked) data to a grayscale TIF and you could probably manipulate and combine those TIFs in Photoshop.  I think at least one of those programs can then do the demosaicking of the combined file, but it's been over a decade since I've used a much earlier version of the software so my recollection may not be 100% and the software may have changed, and nothing that I know of can insert that combined (pre-decmosaicked) data back into a DNG or raw file, so I suppose you can write the software to do that part of the process.

                     

                    Unless you are a spy agency or criminal enterprise trying to alter photographic evidence where the modification is forensically undetectable, I'm not sure what the purpose of working with pre-demosaicked data is, but I'm sure you have a good reason.  It's just that no one else does, so there's no a market for such software.  The software that can create a TIF containing pre-demosaicked data from a raw file is RawDigger, and a program that can possibly do the same thing, plus perhaps demosaick the grayscale TIF into a color TIF is ImagesPlus.  RawDigger is for raw analysis, and ImagesPlus is for astrophotography.

                     

                    And the trouble you're having has nothing to do with the DNG spec, the trouble is the data is raw data, rather than RGB data.  A DNG can actually hold RGB data like a JPG, as well, but it's not raw data, just RGB data.  If you're just trying to trick someone that's not very bright into thinking they are looking at a raw file when it's actually a TIF or JPG then you can open a JPG in the CR plug-in and save it as a DNG, but I don't think that's what you're trying to do, even though it is data in a DNG it wouldn't be raw data, and the ACR plug-in nor Lightroom would treat it as such.  Unlike a DNG containing raw data, a DNG containing JPG (or TIF) data would have only relative white-balance adjustments and no camera profiles, just as if you were adjusting the JPG in ACR or LR.

                    • 7. Re: Editing a DNG file and saving it again as DNG using Photoshop
                      ssprengel Adobe Community Professional & MVP

                      The raw file contains 1-color-per-pixel image data, not 3-colors-per-pixel RGB data.

                       

                      The difference between this:

                       

                      And this:

                      • 8. Re: Editing a DNG file and saving it again as DNG using Photoshop
                        JimHess Adobe Community Professional & MVP

                        I might suggest That you look for a copy of a book, "Real World Camera Raw with Photoshop CS 3) Written by Jeff Schewe. Jeff explains that a raw file is grayscale and contains color information about the color values to be assigned to each pixel. And it takes a raw converter such as Camera Raw (and there are others) to interpret those instructions and apply the color information. I have seen the book in bookstores. I even got one copy through my public library interlibrary loan program. Isn't a big book, and you probably won't need to read all of it. But there is some good information. Obviously, from the title, it's from an older version. And there are editions for other versions as well. But it's good informative reading, and the discussion about the raw file and its characteristics hasn't changed.

                        • 9. Re: Editing a DNG file and saving it again as DNG using Photoshop
                          Abambo Adobe Community Professional

                          You are right, the purpose of the edit seams simple and straight forward. But as all programs I know about that opens DNG (RAW) files interprets and modifies the content, it is quite impossible to do what you ask for.

                           

                          As has been explained before, a RAW file is basically a gray scale image that has been captured through a Bayer filter, making different pixels of the sensor sensitive for one of the primary colours (RGB). I can theoretically imagine editing data in RAW, even having the data displayed demosaiced, but unfortunately, I do not see an application doing this.

                           

                          Photoshop itself does not know about RAW files, that part is taken over by Camera RAW (or Lightroom) Camera Raw and Lightroom do not edit the RAW file, but they only modify the parameters needed to convert the RAW file in a "usable" format. For that reason, you can always undo your modifications (I prefer the term "image interpretations"). Camera RAW passes through an interpreted (therefore strongly permanently modified) RGB image to Photoshop (or even saves as TIFF or JPEG).

                           

                          The way to achieve what you want to do is: Postprocess your data as usual, including the colour grading, by ignoring the fact, that part of one scene is ruined and to merge the correct data after that postprocessing. May be you need to save the intermediate files in a lossless compressed or uncompressed file format, to enjoy full quality.

                           

                          Oh and BTW: There is a lot of data on the web explaining a raw file. I suggest reading the Wikipedia article (Raw image format - Wikipedia, the free encyclopedia) on that and the Bayer pattern (Bayer filter - Wikipedia, the free encyclopedia). You do not need a complete Book for that.

                          • 10. Re: Editing a DNG file and saving it again as DNG using Photoshop
                            dbur971 Level 1

                            I know this is an old thread but:

                             

                            1. Open and edit files in PS.

                            2. save as tiff

                            3. import to lightroom

                            4. export as dng

                            5. done.

                            • 11. Re: Editing a DNG file and saving it again as DNG using Photoshop
                              JimHess Adobe Community Professional & MVP

                              Yes, you can do that. But you still have a tiff image within a DNG wrapper. You no longer have raw image data.