LazPaint and RAW images lazarus / 39-Graphics ---------------------------------------------------------------------- Dick Maley · 2019-10-09 19:12 Can LazPaint edit RAW images? ---------------------------------------------------------------------- circular · 2019-10-11 20:09 Hello I have been thinking about it, though I don't have any RAW images or specifications for that. Are there different RAW formats? What are they? ---------------------------------------------------------------------- winni · 2019-10-11 20:32 @circular Oh, oh, oh! Dont waste your time. Every manufactor has his own proprietary format. Sometimes there is a doc, other companies keep it secret. A good info is from openraw.org: https://www.openraw.org/info/index.html But it seems that there are no activites at openraw since over 10 years. Perhaps they gave up. I wish i could have given you another answer. But the situation needs realy a lot of reverse energeering! Winni ---------------------------------------------------------------------- winni · 2019-10-11 20:56 @circular I forgot: even the Gimp maintainers refused to implement RAW format min their import/export plugins - and there is nearly everthing: image format for astronomers and medicals (X-Ray pictures). And for the "bach to the 80s" there is an asciiart output plugin. But there is a standalone program that converts RAW to known image formats: UFRaw. Short overview at https://expertphotography.com/open-raw-images-gimp- ufraw/#What_Is_UFRaw Homepage at sourceforge: https://www.google.com/url?sa=t&rct=j&q=&esrc =s&source=web&cd=1&cad=rja&uact=8&ved=2ahUKEwikpumXi5XlAhVPJFAKHS6EB9Y QFjAAegQIABAB&url=http%3A%2F%2Fufraw.sourceforge.net%2F&usg=AOvVaw18WQ B2RUvsyd3Xs8I-LF0F Supported cameras are here: http://ufraw.sourceforge.net/Cameras.html Winni ---------------------------------------------------------------------- circular · 2019-10-11 21:38 Hmm yeah maybe it is simpler to use a dedicated program to convert them if there's so much reverse engineering ---------------------------------------------------------------------- circular · 2019-10-15 09:44 There seem to be command line programs that maybe could be interfaced in LazPaint? Or maybe there are already good enough GUI? ---------------------------------------------------------------------- Peter H · 2019-10-15 11:56 I think, dcraw is the standard. (Or has been the standard, because development apparently is stalled) https://www.dechifro.org/dcraw/ Almost any free or commercial raw decoder uses it or portions of it. Raw images are not edited, they are developed into another editable format, eg. tiff. Another possibility is Adobes DNG converter. https://helpx.adobe.com/photoshop/using/adobe-dng-converter.html ---------------------------------------------------------------------- winni · 2019-10-15 16:14 Hi! Adobes DNG converter is poor. Supported Cameras:     Canon EOS RP     Panasonic LUMIX DC-FZ1000M2 (DC-FZ10002)     Panasonic LUMIX DC-S1     Panasonic LUMIX DC-S1R     Panasonic LUMIX DC-ZS80 (DC-TZ95, DC-TZ96, DC-TZ97)     Sony A6400 (ILCE-6400) That's why it is for free! Winni ---------------------------------------------------------------------- Peter H · 2019-10-15 19:34 It /should/ support all cameras which are supported by Adobe Camera Raw (Lightroom, Photoshop) and possibly new cameras that are so new that Camera Raw has no support. Many years ago I used it, but I cannot give instructions. It produces the Adobe DNG format, which is an open standard made by Adobe, and the application must be able to read the DNG format. ---------------------------------------------------------------------- winni · 2019-10-15 19:54 @circular I just stumbled over UFRaw: https://en.wikipedia.org/wiki/UFRaw There is also a command line version for batch files. It works on Linux & Mac & Windows. Perhaps it fits to your needs. Winni ---------------------------------------------------------------------- circular · 2019-10-16 13:46 It seems UFRaw uses dcraw as a backend. So I suppose dcraw is the way. Are there repositories with raw images? Personally i have none. ---------------------------------------------------------------------- winni · 2019-10-16 15:06 @circular I dont no repositories with raw images, but * The university of Waterloo has an ftp directory full of them:   http://links.uwaterloo.ca/Repository/RAW/ * Famous Hasselblad has a page where you can download 16 raw images: https://www.hasselblad.com/learn/sample-images/ * And from 3 "beauty models" you can download raw images. With a lot of color in the face. https://retouchingacademylab.com/free-raw-practice-files/ Enough to start? Winni ---------------------------------------------------------------------- circular · 2019-10-16 16:25 Wonderful  I’ve added the issue on GitHub https://github.com/bgrabitmap/lazpaint/issues/86 ---------------------------------------------------------------------- Peter H · 2019-10-16 17:19 Quote from: winni on October 16, 2019, 05:06:32 pm * The university of Waterloo has an ftp directory full of them:   http://links.uwaterloo.ca/Repository/RAW/ These are not "RAW" images out of digital camera. Too small.  "RAW" images cant be recognized from the extension. The extension is e.g. "ORF" for Olympus, "CRW" for Canon and so on. Each camera vendor has its own proprietary raw format and file extension. "Raw" images contain the original undeveloped (raw) sensordata, uncompressed or lossless compressed and are very large. The size is commonly 10MB and no limit up. You can get raw files from camera review sites for example here: https://www.dpreview.com/reviews/olympus-om-d-e-m1/16 Select "RAW" instead of JPEG, then the file is offered for download. Most cameras have been tested and are available. It should be said, raw image files cannot be simply converted and loaded. They must be deconvoluted and processed before they are visible. The colorspace of the physical camera sensor must be converted to the target color space (commonly sRGB or AdobeRGB) of the image. Noise must be removed. Dead pixels or unusuable pixels (for phase detection) must be interpolated. Possibly geometric distortion and chromatic abberation of the camera lens must be compensated. (DCraw and most open source raw converters dont do this automatically. For this you need a commercial converter, probably these read the maker notes and this content is under NDA and not freely available, it must be reengineered) This is not a straigthforward process. There are a lot of steps where parameter adjustments and decisions must be made which are not fixed, but are a matter of the skills and taste of the photographer. It is probably better to use an existing tool, because photographer who use the raw format of their camera will probably want to use their preferred tool for raw development. ---------------------------------------------------------------------- circular · 2019-10-17 17:15 Thank you for your input Peter. Though two links provided by winni seem to contain images without 'raw' extension. Maybe you were you a bit quick discarding his input. Regarding your detailed explanation, I am not sure I understood your point but what I get from what you say is that dcraw handles almost everything except possible geometric distortion and chromatic abberation of the camera lense. Is it what you were saying? ---------------------------------------------------------------------- lucamar · 2019-10-17 18:37 As Peter said, raw image contain "raw" sensor data (roughly equivalent to an undeveloped negative) along with the camera settings at the time the photo was taken (ISO, white-balance, aperture, shuter speed, etc.). To convert all that to an image (a "positive") the software have to process the data taking into account the settings saved into the file and/or the ones set by the user (you can, for example, adjust the "exposition", the white balance, etc.). The point is that, while not extremely complex, it requires some knowledge of DSP programming (it's not as simple as, say, converting a jpeg to a tiff or png) and the formats used to store the information are mostly propietary and can change without notice. DCRAW does its best to "develop" raw images to an usable format but it can fail to take into account some obscure, changed or obfuscated setting in the file so the result is not always perfect. That said, it's still one of the best alternatives to propietary software and using it is better (and quicker!) than trying to implement your own decoder. ---------------------------------------------------------------------- circular · 2019-10-17 20:14 Ok so the result of dcraw may not be great but it can still be usable, and that's probably the best opensource option, so if I provide it, that's without any guarantee. ---------------------------------------------------------------------- circular · 2019-10-18 14:37 Hi folks I've implemented using dcraw in dev branch of bgrabitmap. On Linux and MacOS, it requires dcraw to be installed. Like 'sudo apt- get install dcraw'. On Windows binaries are provided. When you're testing you need to copy the dcraw binary from bin\Windows\dcraw as dcraw.exe in the same folder as lazpaint*.exe. It all seems to work fine. The thumbnails are a bit slow to load but I guess that's not too bad considering the file sizes. Loading in full definition though takes easily 10 seconds. ---------------------------------------------------------------------- jus · 2019-11-23 01:56 If you are using Windows you can use the Windows Imaging Component to develop the raw files to bmp. I made very little modifications to the Delphi source from here and it compile in Lazarus. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    Memo1: TMemo;    procedure Button1Click(Sender: TObject);  private    { private declarations }    FImagingFactory: IWICImagingFactory;    function JpegToBitmap(const ASource, ATarget: string): Boolean;  public    { public declarations }  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);begin  JpegToBitmap('C:\a\F14_0254.NEF', 'c:\a\F14_0254.bmp');   showmessage('fertig');end; function TForm1.JpegToBitmap(const ASource, ATarget: string): Boolean;var  FileStream: TFileStream;  StreamAdapter: TStreamAdapter;  BitmapInfo: TBitmapInfo;  BitmapBits: array of Byte;  BitmapWidth: Cardinal;  BitmapHeight: Cardinal;  BitmapOutput: graphics.TBitmap;  BitmapObject: IWICBitmap;  BitmapSource: IWICBitmapSource;  BitmapDecoder: IWICBitmapDecoder;  BitmapFrame: IWICBitmapFrameDecode;  i: Integer;  b: hBitmap;begin  if not Assigned(FImagingFactory) then    CoCreateInstance(CLSID_WICImagingFactory, nil, CLSCTX_INPROC_SERVER or      CLSCTX_LOCAL_SERVER, IUnknown, FImagingFactory);   FileStream := TFileStream.Create(ASource, fmOpenRead or fmShareDenyWrite);  try  FileStream.Position := 0;    StreamAdapter := TStreamAdapter.Create(FileStream);     OleCheck(FImagingFactory.CreateDecoderFromStream(StreamAdapter, GUID_NULL,      WICDecodeMetadataCacheOnDemand, BitmapDecoder));    OleCheck(BitmapDecoder.GetFrame(0, BitmapFrame));    OleCheck(FImagingFactory.CreateBitmapFromSource(BitmapFrame,      WICBitmapCacheOnLoad, BitmapObject));    OleCheck(BitmapObject.GetSize(BitmapWidth, BitmapHeight));    SetLength(BitmapBits, BitmapWidth * BitmapHeight * 4);    for i:=0 to 20 do    begin      Memo1.Lines.Add(IntToStr(i)+':'+IntToStr(BitmapBits[i]));    end;    Memo1.Lines.Add('-------------------------------');    OleCheck(WICConvertBitmapSource(GUID_WICPixelFormat32bppBGRA, BitmapObject,      BitmapSource));    OleCheck(BitmapSource.CopyPixels(nil, BitmapWidth * 4, Length(BitmapBits),      @BitmapBits[0]));     FillChar(BitmapInfo, SizeOf(BitmapInfo), 0);    BitmapInfo.bmiHeader.biSize := SizeOf(BitmapInfo);    BitmapInfo.bmiHeader.biWidth := BitmapWidth;  BitmapInfo.bmiHeader.biHeight := -BitmapHeight;    BitmapInfo.bmiHeader.biPlanes := 1;    BitmapInfo.bmiHeader.biBitCount := 32;     BitmapOutput := TBitmap.Create;    B := CreateBitmap(BitmapWidth, BitmapHeight, 1, 32, @BitmapBits[0]);    try      BitmapOutput.PixelFormat := pf32bit;      BitmapOutput.SetSize(BitmapWidth, BitmapHeight);      //SetDIBits(0, BitmapOutput.Handle, 0, BitmapHeight, @BitmapBits[0], BitmapInfo, DIB_RGB_COLORS);      SetDIBits(0, b, 0, BitmapHeight, @BitmapBits[0], BitmapInfo, DIB_RGB_COLORS);      //BitmapOutput.AlphaFormat := afDefined;      BitmapOutput.LoadFromBitmapHandles(b,0);      //BitmapOutput.CreateFromBitmapHandles(B, 0, Rect(0, 0, BitmapWidth, BitmapHeight))      BitmapOutput.SaveToFile(ATarget);    finally      DeleteObject(b);      BitmapOutput.Free;    end;  finally    FileStream.Free;  end;end; end.  Before you use it you have to download your camera raw supportpackage for windows imaging component from your camera manufacturer homepage first. ---------------------------------------------------------------------- circular · 2019-11-28 22:53 Interesting, that's worth trying out