HDR tone mapping

If my understanding is correct, "exposure and gamma" 32-bit to 8-bit  HDR conversion method works as
[new value] = ( [old value] * 2^[exposure]) ^ (1/gamma)
Is this right?
Is it applied to each  - r, g and b  - channel ?
How are the resulting values further proceeded to fit in 0...255 range? 
I would be very grateful if you help me understand the way hdr images are displayed in photoshop.

Definitely wasted my money on this poor product. Thanks for all the help folks but think I may just give up on adobe all together and get one of the other editing software programmes. One that will allow me to carry out tone mapping on raw images and offer true hdr. The photomerge/hdr function is good but tone mapping gives better more professional results, so think I will go to another programme.
Date: Wed, 5 Jun 2013 13:26:13 -0700
From: [email protected]
To: [email protected]
Subject: Tone Mapping & HDR Imaging
    Re: Tone Mapping & HDR Imaging
    created by R_Kelly in Photoshop Elements - View the full discussion
I don't believe you can add a true hdr plugin to photoshop elements because photoshop elements doesn't handle 32 bits/channel files
in the editor like photoshop cs2-cs6 can.
There are several free hdr programs if you want to try true hdr.
Then you can save the resulting hdr 32 bits/channel file as a tiff and open that file into camera raw from pse 11.
http://qtpfsgui.sourceforge.net/
http://www.hdrlabs.com/picturenaut/
     Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5382669#5382669
     Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5382669#5382669
     To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5382669#5382669. In the Actions box on the right, click the Stop Email Notifications link.
     Start a new discussion in Photoshop Elements by email or at Adobe Community
  For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

Similar Messages

  • HDR Tone Mapping in Action?

    Hi - and thanks in advance for any insight you may be able to offer -
    Photoshop CS5 V12.0.2, Mac 10.6.6, trying to create an action to batch process a time lapse sequence. When I include HDR tone mapping as part of that action, even with using a preset I had made and saved, the script pauses at the tone mapping stage and shows the "default" settings, waiting for me to input specifics and press OK.
    I've got about 5400 frames that need to be processed from three different captures. Any help in automating this process would be greatly appreciated!
    With Thanks,
    Rich

    Many thanks.
    And yes it works and results are similar to the tone mapping in PSP.

  • Tone Mapping & HDR Imaging

    I am having trouble with learning a few things on PSE 11. I have managed to do my HDR images but I would also like to add tone mapping to single images the forums and tutorial videos only seem to cover these in the professional CS products. surley PSE 11 has this function though can anybody help as I say I know how to create a HDR image but not tone mapping on one single image.

    Definitely wasted my money on this poor product. Thanks for all the help folks but think I may just give up on adobe all together and get one of the other editing software programmes. One that will allow me to carry out tone mapping on raw images and offer true hdr. The photomerge/hdr function is good but tone mapping gives better more professional results, so think I will go to another programme.
    Date: Wed, 5 Jun 2013 13:26:13 -0700
    From: [email protected]
    To: [email protected]
    Subject: Tone Mapping & HDR Imaging
        Re: Tone Mapping & HDR Imaging
        created by R_Kelly in Photoshop Elements - View the full discussion
    I don't believe you can add a true hdr plugin to photoshop elements because photoshop elements doesn't handle 32 bits/channel files
    in the editor like photoshop cs2-cs6 can.
    There are several free hdr programs if you want to try true hdr.
    Then you can save the resulting hdr 32 bits/channel file as a tiff and open that file into camera raw from pse 11.
    http://qtpfsgui.sourceforge.net/
    http://www.hdrlabs.com/picturenaut/
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5382669#5382669
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5382669#5382669
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5382669#5382669. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Photoshop Elements by email or at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Missing HDR tonning presets ic SC5 x64?

    CS5 missing my HDR tonning presets,
    When i upload images in
    Automate-Merge to HDR Pro and want to use the presets everything goes to 0 (all the way to the left on the sliders)???
    it seems i need to instal the presets, i guess?
    can someone help me with this please?
    Many thanks,

  • Availability of HDR Toner plug-in

    Does anyone have an update on the availability of dvGarage's HDR Toner plug-in? Last I heard was June 15, but the plug-in was due in late April, then mid May and then mid June. There is no mention of the application on the website so I assume the mid June date will be missed as well.
    Let me know if anyone has an update.
    Also are any other HDR plug-ins available currently available? I know there is one (Hydra), but it creates a TIFF file rather than the non-destructive change and per the boards it has a number of flaws.
    Thanks
    Message was edited by: ejg999

    Thank you CorkyO2.
    I just took a look at this software and I think the 15 day trial would be great.
    But to buy it would cost U$149. That's a bit too much in my case since I'm not a commercial photographer (maybe someday) and just want to do HDR for personal use with few pics.
    I'd pay U$ 79 for Aperture since it's a more generic product and I feel ready to move from iPhoto to Aperture and learn new things.
    But 149 specifically for HDR was not my idea right now.
    - Do you know of other free or cheaper plug-ins or softwares?
    - Is there anything that works with iPhoto?
    - I did a search and found this. Do you know it? ->   http://www.hdrsoft.com
    - And also this Luminance HDR. Do you know it? -> http://qtpfsgui.sourceforge.net
    thanks and regards

  • How to Set Lens Profiles on a tone mapped HDR

    I'm trying to work out the optimal workflow for doing HDR (using HDR EFEX 2) on a set of images. 
    I can apply LR's Lens Correction (Nikon, 17-55mm F2,8) and chromatic aberation removal on the whole set set (using LR Sync) before I export to HDR - then turn off the Chromatic Aberation fix in HDR - and that gives me one workflow.
    However, that makes a lot of changes to the TIF's before I go in - so I am wondering if it would be better to export the RAW files converted to TIF using minimal changes from LR e,g, no CA fix or Lens Profile correction; let the HDR do its thing and then make profile corrections, Upright, etc upon return from HDR.  However, when I get back from HDR and go into Develop with the returned file and go to Lens Correction, I cannot chose the 17-55mm F2.8 lens from the drop downs.  There are only about 4 or 5 lenses now showing as Nikon possibilities-and the 17-55 is NOT among them.
    How come I don't still see the full list of Nikon profiles - shoudln't I be able to apply any profile to a TIF (even an incorrect one) ?
    I tried pasting the Develop Settings from a virtual copy where I had set the Lens Profile to 17-55 F2.8 - but that only turns on the Lens Profile 'filter' and does not actually force-on the specific correction.
    Any thoughts ?
    JC

    Since lens profiles are format-specific, is that the source of your problem?

  • Improve HDR images in Aperture

    Hi,
    I've recently been trying HDR photography, and so far the results have been pretty poor.  I'm currently using the Photomatix HDR Tone Mapping plug-in for Aperture 2.0.
    Every time I produce an image, they come out very cartoony, and not at all like the beautiful landscaped examples you see on the net.  I've also had a bash with Photoshop's HDR tool, with similar unsatisfactory results.
    Can anyone give me some thoughts as to where I may be going wrong?  Is there a limitation to this particular plug-in? Or is there a problem with my technique.  (At present I'm only using 3 exposures.  Would going to 7 produce more natural looking final images)?
    So far, I've found that shooting raw and adjusting highs and lows carefully is producing better results than HDR for me.
    I have a job coming up which is for a bar in a skyscraper and I want to produce some really spectacular shots, with good range in the interior and exterior areas.
    Any help or thoughts would be fantastic.
    Thank you.
    Richard

    Most times when HDR images come out cartoonish the fault is in trying to do to much. The results are usually better if the HDR effect is kept to a minimum.
    Another thing to keep in mind is that not all scenes lend themselves to an HDR interpertation. And the correct exposure series can have a huge effect on the final result. While the software will make creating an HDR image easy the final result, as you are finding out, is still in the hands of the photographer.
    You might also want to chack out NIK Software's HDR plug-in. They have a free trial. They also have a number of free online seminars and instructional videos. See Nik Software

  • Merge to HDR Pro from LR4

    I am using LR4 and edit/merge to HDR Pro in CS5. The images appear in CS5 as the processing is going on but then it just terminates and the images disappear from CS5.  This is happening on multiple sets of images not just one set.  I don't know if this is part of the problem but I also get a message as the process is starting on LR that I may need Camera Raw Version 7 but I can't find that anywhere.  Any idea what's going on?
    Thanks

    Hi Bill,
    Answers to your questions beow ...
    The one thing that I did not see was your HDD setup, and especially how you have your HDD's allocated, with such things as Scratch Disks, etc. That might be useful knowledge.
    -  Just use a single 1TB hard disk, 516GB used and 398GB free.
    With Win7-64, the 8GB RAM is a bit light, as Win7-64 is a RAM hog, and Scratch Disks will most likely come into play, and especially with HDR.
    - Can't do much about that as 8GB is the MAX on the motherboard. But again don't have any problems in any other areas and if I do Tone Mapping from the Image -> Adjustments -> HDR Tone Mapping ... menu there aren't any issues.
    Now, if you do NOT switch out of PS, while doing an HDR Merge, does it then complete, i.e. is it only when it loses focus, that it hangs?
    - Yes, as long as I don't switch out at all.
    What are your PS Memory and Cache settings?
    - Available RAM 7230, Let Photoshop Use: 4338 (60%) (This is the default setting Photoshop chose)
    - Cache Settings, again default: Cache Levels: 4, Cache Tile Size: 1024K.
    Do you have any active-scanning anti-virus, anti-malware, anti-anything running?
    - Yes, Microsoft Security Essentials
    Is Windows Indexing ON - though with Win7-64, it has become much less of a problem, than with older OS's?
    - Yes Indexing is on, makes no difference if I turn it off.
    What are the Image Size of the HDR Images?
    - As they are from Canon 5D Mk II (ProPhoto RBG, 16 bit, 5616 x 3744 (~21MP) and 300 bit/in) they will open anywhere up to 120MB in TIFF or PSD.
    I am not sure but it seems a little similar to the issue with the CA sliders in LR4 Beta when we reverted back to Process 2010 after upgrading to PV2012 unless there is a memory leak somewhere. Again if I use NIK Software HDR Efex pro I don't seem to have any of these issue - (just aligment and ghosting ).
    Obviously I have a work around by simply not leaving the HDR Merge window before completing the process, just inconvenient.
    Regards, Don

  • HDR in Aperture

    Hi.
    How do I make an HDR picture i Aperture. I have seen videos on youtube but they were doing it so fast.
    I know that I have to take several pictures with diff. shutterspeed

    Allansteff,
    Welcome to the user-supported Aperture discussion forum. You should read the [Terms of use|http://discussions.apple.com/help.jspa] that Apple requests we abide by.
    How do I make an HDR picture i Aperture
    As far as I know, Aperture doesn't support any HDR formats. You can tone-map an HDR image generated from an external program and then import that into Aperture. What I generally do is stack the "component" photos in Aperture. (I stack them so I have all the associated photos together.) Then I use my external program to merge the photos and tone-map them to produce a JPG. I import that JPG and stack it with the component photos, making the new one the stack pick. Then I compare the well-exposed photo with the HDR tone-mapped one to see if I actually did something worthwhile.
    I have not used any HDR plugin programs for Aperture, but they exist. I believe they short-cut the export/import process to make it more seamless.
    I generally export to a predefined directory and then launch my HDR program manually to work on the component photos in that directory.
    [Apple - Aperture - Plug-ins|http://www.apple.com/aperture/resources/plugins.html#editing]
    nathan

  • Error 48: File or folder does not exist.

    I get this error when trying to access HDR tone mapping.   Can anyone help.

    If the error is showing up, when doing a training series, I need to ask: Does that training series come with Images, etc., to be used in the training? Some come with 3rd party plug-ins (usually a trial version), but some do not provide materials. It just depends.
    If so, did you install those, where directed?
    Which training series are you working with?
    Good luck,
    Hunt

  • A few questions about OpenGl acceleration

    My system:
    Vista Ultimate 32bit, Intel Q6600, Geforce 8600GT/512MB, 4G Ram, newest card driver.
    1. Do the graphics driver setting have any influence on Photoshop? If yes, what are the recommended settings?
    2. Flick panning is stuttering a bit. Is my card too slow then?
    3. When I do "flick-panning" it sometimes happens, that I get to an area of the picture that is displayed extremely blurry. That means I start flick-panning in a sharp area and after a second or so I get to a blurred area. The graphics card seems to wait until the pannnig stops completely before it renders the picture sharp. Why doesn`t it render the picture sharp WHILE panning? Again, is my card too slow?
    4. Birdseye view. If I`m zoomed in in a very large picture and press the H-key and press the mouse button to zoom out (birdeye view) I often get a view of the picture that is partly blurred. As soon as I release the mouse to zoom in again it gets sharp....but not before (in the zoomed out-view).
    5. Color management: To get colormanagement I have to switch on "color matching" in the advanced OpenGl options. Otherwise the picture is displayed like in a browser without colormanagement. But if this option is on, I get slight banding in a black/white gradient in the shadows.
    This gets really ugly if I make a black/white gradient in a huge colorspace like ProPhoto.
    6. When OpenGl is off, screen redrawing is much slower than in CS3.
    In CS3 it takes about 1/10sec for the whole picture (my screen res is 1024/1200), in CS4 it takes about 5/10sec (just estimating).
    The side effect of this is that no matter wether OpenGL is on or off, moving parts of the picture with the move tool is MUCH slower than in CS3.
    After all, don`t get me wrong....I really like the new GPU stuff. Just trying to figure out wether I can get it even better.
    Can some of you Adobe guys explain, please?

    Stefan, I just installed a new EVGA nVidia GTX 9800 card with 512MB onboard. I've been looking for any help on the advanced "use OpenGL drawing" preference options and haven't found anything.
    Is "flick panning" where you use the hand tool to activate a pan - and with hardware acceleration you get a ballistic response? Adobe calls it a hand toss. I get some mild stuttering doing that. Compared to the ATI FireGL v3400 card I just replaced, dynamic zooming is smoother with the new card, but the ballistics is something I'd like to disable so there's no lag when I lift my stylus before zooming stops.
    Doing bird's eye view most of the time I'm not seeing any artifacts, but occasionally I see a rectangular area within the full image view blurry (as if it's the first step in a progressive rendering).
    The 178.24 nVidia control panel lets you adjust settings for individual applications. As far as I can tell, only the feature "Multi-display/mixed-GPU acceleration" is different than the global settings with its boldface "compatibility performance mode" enabled.
    If I disable "color matching" in the advanced drawing GPU preferences, if convert a wide gamut image to sRGB, the preview in the conversion control panel is fine, but after conversion the image is no longer color managed. It's very obvious on my wide gamut display. If I save the image, it converted as previewed and will display accurately when reopened.
    I think CS4 without GPU enhancement is a slug compared to CS3. I think there will be a mass movement to graphics card upgrades with this release.
    Bridge color management turns off if I enable "software rendering" in preferences. So I can either have unscrambled pdf previews after page one in some documents, or I can have CM working - but not both. This is consistent between my new graphics adapter and my old one. I got the new one to get past the severe 128MB limitations on Photoshop's OpenGL performance. PS gave me warnings that GPU acceleration would work with only two windows open, and tonight I found technotes with some tantalizing but unspecific information:
    This technote talks about the features vs. onboard graphics memory:
    http://kb.adobe.com/selfservice/viewContent.do?externalId=kb405745
    This technote has troubleshooting info, and some information on the advanced GPU preferences:
    http://kb.adobe.com/selfservice/viewContent.do?externalId=kb404898
    "Q. What are all those Advanced Settings options and what do they mean?
    A. Advanced Settings options:
    Vertical Sync: Reduces tearing by syncing the frame rate to that of the display.
    3D Interaction Acceleration: Increases the clicking speed when working with 3D forms. If you experience drawing problems that correct themselves when you let up on the mouse button, turn this option off.
    Force Bilinear Interpolation: Tells the GPU to perform high precision modeling and smoothing functions when you use a card that doesn't support those functions for certain image types.
    Advanced Drawing: Allows the GPU to perform, and therefore speed up, certain tasks, such as color matching, depth conversion, HDR tone mapping, and checkerboard compositing.
    Use For Image Display: Doubles the use of video RAM used to display the main image when you use multiple images, large images, or large 3D models. It's available only on display cards that have 512 MB RAM or more.
    Color matching: Can be used to avoid the display of visual artifacts."
    So is color management going away a "visual artifact" - as usual, you have to dig to find basic help info and it's usually very sketchy when you do find it.
    I'd like to invite all the self-appointed forum enforcers to take a hike. If you have a problem with a post or reply, save us from having to wade through your petty, snarky responses. You're not contributing and you're not entertaining anyone but yourselves.

  • Batch HDR Merging/Toning Script

    I've seen a number of different posts on these forums about trying to do this and I never really found a complete and suitable solution. It also has really annoyed me that adobe never implemented this (and it's not possible to do with actions because the action just runs a script and you can't record the HDR toning settings, the dialog always pops up, its in the script). So I finally had some time to get my hands dirty with ExtendScript and I have created a fully featured script complete with UI that allows batch creation of HDR tonned images in photoshop.
    The code I got working from various snipets of code I found around the 'net and single stepping through the MergeToHDR.jsx script that is built into photoshop.
    This has only been partially tested on photoshop CC on a mac. Hopefully I made it portable enough and it will work on windows and older versions. I don't think the MergeToHDR script has changed much in the last several versions (and that is mainly what I call to do the work) so I think it should work. If you have issues please let me know.
    My motivation for this script was coming up with a way to do batch HDR toning for timelapse and so this script's features lean toward using it for that end. I really didn't want to buy another separate program for doing this like photomatix, when I knew it should at least be possible to do in photoshop.
    I uploaded the script to github:
    https://github.com/davidmilligan/PhotoshopBatchHDR/blob/master/Batch%20HDR.jsx
    How to use:
    Drop the script in the '[photoshop folder]/presets/scripts' folder and restart photoshop if it is already running.
    The script should appear as a menu item under File>Automate>Batch HDR...
    A dialog will appear where you specify all the settings for the batch
    Input Section:
    Click browse and select the source folder that contains the images to be merged/toned
    Specify "Number of Brackets" this is how many separate images to group into a single HDR output image (the script will group the images in the source folder in order based on this parameter). You can use a value of 1, which means each image in the source folder is separate and will be toned and output. (I find that many times when shooting RAW, 14 bits is ample to capture the full dynamic of the scene, so I do not waste storage space and shutter acutations using more than one exposure, just make sure to ETTR, also post-processing with this script will be faster)
    If there are other files in your source folder (for example .xmp files) that you need to exclude you can specify a filte. For example: *.cr2
    Typically for timelapse you are using a tripod and do not need to have photoshop align the images, but I provided that capability for anyone who might need it b/c it was easy to enable. Note that enabling this will make the process MUCH slower.
    Toning Section:
    These settings are all the same as the photoshop HDR toning dialog for "Local Adaptation"
    To preview what your toning settings will look like you can select any file(s) in your sequence by clicking "Select File(s)..." under "Preview". The file(s) you select will open and merge (if more than one file). When that's finished you can click the "Update Preview" button to apply the current toning settings and see what they will look like (I can't do the fast, automatic previews like the builtin dialog, sorry - somebody from adobe want to show me how to do this?)
    You can see what the settings will look like at another point in your sequence by clicking the "Select File(s).." button again. (I recommend previewing a shot near the beginning, middle, and end of your sequence)
    The dialog prevents you from using anything in photoshop while its open so I provided a zoom to allow you to zoom in on the preview
    The tone curve you must enter as a comma separated list of points (sorry, ScriptUI is not really adequate to create the graphical histogram overlay for the curves like in the builtin dialog). The points are grouped into x,y pairs so for example: x1,y1,x2,y2,etc. Typically you will start with 0,0 and end with 255,255 (note that 255 is the max, full white). Like the curves tool, x represents the input and y represents the output
    Output Section:
    Click browse and select a folder for the script to save the output files to
    The rest of this section should be self explanitory. NOTE: If you select to output 32bit files, the toning will not be applied, the files will simply be merged into a 32bit HDR image and saved.
    Once you have specified the input and output folders the OK button should be enabled, when you are ready, click OK to start the process
    Go watch a movie or take a nap, this is going to take a while. The script will display a progress window showing you how far along the proces is (the photoshop progress windows may occasionally appear on top of it, I usually just move them up a little so I can see both)
    Limitations:
    Only the local adaptation method is supported. It's really the only one I ever use, and I didn't really feel like implementing the other ones, but feel free to modify the script yourself to add this support
    You canot load or save presets from the builtin toning dialog. The format of the preset files is binary and would require reverse engineering of the format and it would be very difficult to read to the files in javascript anyway. If it were xml, it would be much easier, alas it is not. Feel free to grab a hex editor and do this yourself. For now you'll just have to copy all of the values of a preset by hand into the dialog if you want to use a preset. If I have more time this is something I might work on.
    Preview is slow because it has to do the actual full toning, I don't know a way to do the fast real time previews like the builtin dialog.
    I don't think the "Cancel" button on the progress window really works, once running, the script is too busy to register a click, anybody know how I might fix this?
    There may potentially be some ways to improve performance of this script in certain scenarios, IDK, but I'm just glad it works
    You're welcome Adobe, you can send me a check at:
    [REDACTED]
    [REDACTED]
    [REDACTED]
    Please hit me up with comments/suggestions,
    David

    Thank you for your script, it's very useful.
    I just changed a few things :
    The Checkboxes didn't work so I changed them :
    alignCheckBox.onChanged by alignCheckBox.onClick
    deghostCheckBox.onChanged by deghostCheckBox.onClick
    smoothEdgesBox.onChange by smoothEdgesBox.onClick
    And for best alignment, I changed :
    mergeToHDR.mergeFilesToHDR( currentFileList, false, hdrDeghosting ? kMergeToHDRDeghostBest : kMergeToHDRDeghostOff );
    by :
    mergeToHDR.mergeFilesToHDR( currentFileList, mergeToHDR.useAlignment, hdrDeghosting ? kMergeToHDRDeghostBest : kMergeToHDRDeghostOff );
    And lastly :
    My language is french so I had to modify loadPreset function because my own preset file contains the string "P a r   d é f a u t" in place of "D e f a u l t" so that the data is shifted.
    Here is the code :
    #target photoshop
    Batch HDR Script by David Milligan
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    // BEGIN__HARVEST_EXCEPTION_ZSTRING
    <javascriptresource>
    <name>Batch HDR...</name>
    <menu>automate</menu>
    </javascriptresource>
    // END__HARVEST_EXCEPTION_ZSTRING
    //these lines import the 'Merge To HDR.jsx' script that is built in to photoshop, we will make calls to that script and some of the scripts that it includes
    var runMergeToHDRFromScript = true;
    var g_ScriptFolderPath = app.path + "/"+ localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts");
    var g_ScriptPath = File( g_ScriptFolderPath+'/Merge To HDR.jsx' );
    $.evalFile( g_ScriptPath );
    //$.level = 2;
    //default settings:
    mergeToHDR.useAlignment = false;
    mergeToHDR.useACRToning = false;
    var numberOfBrackets = 3;
    var userCanceled = false;
    var sourceFolder;
    var outputFolder;
    var saveType = "JPEG";
    var jpegQuality = 10;
    var progress;
    var statusText;
    var progressWindow;
    var fileMask = "*";
    var outputFilename = "hdr_output_";
    var hdrRadius = 100;
    var hdrStrength = 0.5;
    var hdrGamma = 1.0;
    var hdrExposure = 0.0;
    var hdrDetail = 100;
    var hdrShadow = 0;
    var hdrHighlights = 0;
    var hdrVibrance = 20;
    var hdrSaturation = 30;
    var hdrSmooth = false;
    var hdrDeghosting = true;
    var hdrCurve = "0,0,255,255";
    var estTimeRemaining = "";
    var previewDoc;
    var originalDoc;
    function main()
        promptUser();
        //make sure user didn't cancel
        if(sourceFolder != null && outputFolder != null && sourceFolder.exists && outputFolder.exists && numberOfBrackets > 0)
            initializeProgress();
            var files =  sourceFolder.getFiles(fileMask);
            var currentFileList = new Array();
            for(var index = 0;  index < files.length; index++)
                if((index % numberOfBrackets) == numberOfBrackets - 1)
                    var start = new Date();
                    progress.value = 100 * index / files.length;
                    currentFileList.push(files[index]);
                    if(userCanceled) break;
                    if(numberOfBrackets > 1)
                        statusText.text = "Merging files "+(index-numberOfBrackets+2)+" - "+(index+1)+" of "+files.length + estTimeRemaining;
                        //for braketed exposures use the mergeToHDR script to merge the files into a single 32 bit image
                        mergeToHDR.outputBitDepth= 32;
                        mergeToHDR.mergeFilesToHDR( currentFileList, mergeToHDR.useAlignment, hdrDeghosting ? kMergeToHDRDeghostBest : kMergeToHDRDeghostOff );
                        statusText.text = "Toning files "+(index-numberOfBrackets+2)+" - "+(index+1)+" of "+files.length+ estTimeRemaining;
                    else
                        statusText.text = "Loading file "+(index+1)+" of "+files.length+ estTimeRemaining;
                        //otherwise just open the file
                        doOpenFile(files[index]);
                        statusText.text = "Toning file "+(index+1)+" of "+files.length+ estTimeRemaining;
                    progress.value = 100 * (index + numberOfBrackets / 2 ) / files.length;
                    if(userCanceled) break;
                    if(app.activeDocument != null)
                        //apply the actual tone mapping to the HDR image to get it back down to 8 bits
                        doHDRToning();
                    //save the result and close
                    //TODO: add leading zeros to index in filename
                    if(numberOfBrackets > 1)
                        statusText.text = "Saving result "+(index-numberOfBrackets+2)+" - "+(index+1)+" of "+files.length+ estTimeRemaining;
                    else
                        statusText.text = "Saving result "+(index+1)+" of "+files.length+ estTimeRemaining;
                    if(userCanceled) break;
                    doSaveFile(outputFolder.absoluteURI + "/" + outputFilename + ZeroPad(Math.round((index + 1)/numberOfBrackets), 5) );
                    activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                    //reset our file list
                    currentFileList = new Array();
                    //calculate time remaining
                    var end = new Date();
                    var timeElapsed = end.getTime() - start.getTime();
                    var mins = timeElapsed / 60000 * ((files.length - index - 1) / numberOfBrackets);
                    estTimeRemaining = " | Remaining: " + ZeroPad((mins / 60).toFixed(0),2) + ":" + ZeroPad((mins % 60).toFixed(0),2);
                else
                    currentFileList.push(files[index]);
            progressWindow.hide();
    function doOpenFile(filename)
        const eventOpen = app.charIDToTypeID('Opn ');
        var desc = new ActionDescriptor();
        desc.putPath( typeNULL, new File( filename ) );
        desc.putBoolean( kpreferXMPFromACRStr, true ); //not sure what this does or if it is needed
        executeAction( eventOpen, desc, DialogModes.NO );
        //if we don't convert the image to 32bit the mergeToHDR script will not tone our image when we call it, it will simply downconvert it to 8 bit
        convertTo32Bit ();
    function convertTo32Bit()
        var idCnvM = charIDToTypeID( "CnvM" );
        var desc6 = new ActionDescriptor();
        var idDpth = charIDToTypeID( "Dpth" );
        desc6.putInteger( idDpth, 32 );
        var idMrge = charIDToTypeID( "Mrge" );
        desc6.putBoolean( idMrge, false );
        var idRstr = charIDToTypeID( "Rstr" );
        desc6.putBoolean( idRstr, false );
        executeAction( idCnvM, desc6, DialogModes.NO );
    function doSaveFile(filename)
        if(saveType == "JPEG")
            var jpgSaveOptions = new JPEGSaveOptions();
            jpgSaveOptions.embedColorProfile = true;
            jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
            jpgSaveOptions.matte = MatteType.NONE;
            jpgSaveOptions.quality = jpegQuality;
            activeDocument.saveAs(new File(filename), jpgSaveOptions, true /*Save As Copy*/, Extension.LOWERCASE /*Append Extention*/);
        else if(saveType == "TIFF")
            var tifSaveOptions = new TiffSaveOptions();
            tifSaveOptions.embedColorProfile = true;
            activeDocument.saveAs(new File(filename), tifSaveOptions, true /*Save As Copy*/, Extension.LOWERCASE /*Append Extention*/);
        else if(saveType == "TIFF LZW")
            var tifSaveOptions = new TiffSaveOptions();
            tifSaveOptions.embedColorProfile = true;
            tifSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
            activeDocument.saveAs(new File(filename), tifSaveOptions, true /*Save As Copy*/, Extension.LOWERCASE /*Append Extention*/);
        else if(saveType == "TIFF ZIP")
            var tifSaveOptions = new TiffSaveOptions();
            tifSaveOptions.embedColorProfile = true;
            tifSaveOptions.imageCompression = TIFFEncoding.TIFFZIP;
            activeDocument.saveAs(new File(filename), tifSaveOptions, true /*Save As Copy*/, Extension.LOWERCASE /*Append Extention*/);
        else
            activeDocument.saveAs(new File(filename), undefined, true /*Save As Copy*/, Extension.LOWERCASE /*Append Extention*/);
    function doHDRToning()
        //TODO: Reverse engineer the HDR Preset file format and allow user to select a preset file and create the ActionDescriptor from the file
        //create the ActionDescriptor that describes the HDR toning settings to use
        var hdDesc = new ActionDescriptor;
        hdDesc.putInteger( stringIDToTypeID( 'version' ), 6 );//I'm not sure what this does
        hdDesc.putInteger(  kmethodStr, 3 );// the toning method to use, 3 = local adaptation
        hdDesc.putDouble( stringIDToTypeID( 'radius' ), hdrRadius );
        hdDesc.putDouble( stringIDToTypeID( 'threshold' ), hdrStrength );// strength
        hdDesc.putDouble( stringIDToTypeID( 'center' ), hdrGamma );// gamma
        hdDesc.putDouble( stringIDToTypeID( 'brightness' ), hdrExposure );// exposure
        hdDesc.putDouble( stringIDToTypeID( 'detail' ), hdrDetail );
        hdDesc.putDouble( stringIDToTypeID( 'shallow' ), hdrShadow );
        hdDesc.putDouble( stringIDToTypeID( 'highlights' ), hdrHighlights );
        hdDesc.putDouble( stringIDToTypeID( 'vibrance' ), hdrVibrance );
        hdDesc.putDouble( stringIDToTypeID( 'saturation' ), hdrSaturation);
        hdDesc.putBoolean( stringIDToTypeID( 'smooth' ), hdrSmooth );
        hdDesc.putBoolean( stringIDToTypeID( 'deghosting' ), hdrDeghosting );
        //create the tone curve
        var cDesc = new ActionDescriptor;
        cDesc.putString( stringIDToTypeID( 'name' ), 'Default');
        var cList = new ActionList;
        var points = hdrCurve.split(',');
        for(var i = 0; i < points.length; i++)
            if(i % 2 == 1)
                var pDesc = new ActionDescriptor;
                pDesc.putDouble( stringIDToTypeID( 'horizontal' ), points[i-1] );
                pDesc.putDouble( stringIDToTypeID( 'vertical' ), points[i] );
                pDesc.putBoolean( keyContinuity , false );// ?????
                cList.putObject( charIDToTypeID( 'Pnt ' ), pDesc );
        cDesc.putList( stringIDToTypeID( 'curve' ), cList );
        hdDesc.putObject( kclassContour, classShapingCurve, cDesc );
        //call the script that actually invokes the toning plugin
        convertFromHDRNoDialog( outputBitDepth, hdDesc );
    function initializeProgress()
        progressWindow = new Window("palette { text:'Batch HDR Progress', \
            statusText: StaticText { text: 'Processing Images...', preferredSize: [350,20] }, \
            progressGroup: Group { \
                progress: Progressbar { minvalue: 0, maxvalue: 100, value: 0, preferredSize: [300,20] }, \
                cancelButton: Button { text: 'Cancel' } \
        statusText = progressWindow.statusText;
        progress = progressWindow.progressGroup.progress;
        progressWindow.progressGroup.cancelButton.onClick = function() { userCanceled = true; }
        progressWindow.show();
    function promptUser()
        var setupWindow = new Window("dialog { orientation: 'row', text: 'Batch HDR', alignChildren:'top', \
            leftGroup: Group { orientation: 'column', alignChildren:'fill', \
                inputPanel: Panel { text: 'Input', \
                    sourceGroup: Group { \
                        sourceBox: EditText { characters: 40, text: '' }, \
                        sourceBrowse: Button { text: 'Browse' } \
                    bracketGroup: Group{ \
                        bracketLabel: StaticText { text: 'Number of Brackets: ' }, \
                        bracketBox: EditText { characters: 2 }, \
                        filterLabel: StaticText { text: 'File Filter: ' }, \
                        filterText: EditText { characters: 5 }, \
                        alignCheckBox: Checkbox { text: 'Align' }\
                        deghostCheckBox: Checkbox { text: 'Deghost' }\
                toningPanel: Panel { text: 'Toning', orientation:'row', alignChildren:'top' } ,\
                outputPanel: Panel { text: 'Output', \
                    outputGroup: Group { \
                        outputBox: EditText { characters: 40, text: '' }, \
                        outputBrowse: Button { text: 'Browse' } \
                    outputOptionsGroup: Group { \
                        outputFilenameLabel: StaticText { text: 'Filename Format: ' }, \
                        outputFilenameText: EditText { characters: 10 }, \
                        outputFilenamePost: StaticText { text: '00001.jpg' }, \
                    saveSettingsGroup: Group { \
                        saveTypeLabel: StaticText { text: 'Save As: ' }, \
                        saveDropDown: DropDownList { }, \
                        jpegQualityLabel: StaticText { text: 'JPEG Quality (1-10): ' }, \
                        jpegQualityText: EditText { characters: 2}, \
                        outputBitDepthLabel: StaticText { text: 'Bit Depth', enabled:false }, \
                        outputBitDepthDropDown: DropDownList { enabled:false }, \
            rightGroup: Group { orientation: 'column', alignChildren:'fill', \
                okButton: Button { text: 'OK', enabled: false } \
                cancelButton: Button { text: 'Cancel' } \
        generateToningPanel(setupWindow.leftGroup.toningPanel);
        //shortcut variables
        var sourceBox = setupWindow.leftGroup.inputPanel.sourceGroup.sourceBox;
        var sourceBrowse = setupWindow.leftGroup.inputPanel.sourceGroup.sourceBrowse;
        var bracketBox = setupWindow.leftGroup.inputPanel.bracketGroup.bracketBox;
        var filterText = setupWindow.leftGroup.inputPanel.bracketGroup.filterText;
        var alignCheckBox = setupWindow.leftGroup.inputPanel.bracketGroup.alignCheckBox;
        var outputBox = setupWindow.leftGroup.outputPanel.outputGroup.outputBox;
        var outputBrowse = setupWindow.leftGroup.outputPanel.outputGroup.outputBrowse;
        var outputFilenameText = setupWindow.leftGroup.outputPanel.outputOptionsGroup.outputFilenameText;
        var saveDropDown = setupWindow.leftGroup.outputPanel.saveSettingsGroup.saveDropDown;
        var jpegQualityText = setupWindow.leftGroup.outputPanel.saveSettingsGroup.jpegQualityText;
        var jpegQualityLabel = setupWindow.leftGroup.outputPanel.saveSettingsGroup.jpegQualityLabel;
        var outputBitDepthDropDown = setupWindow.leftGroup.outputPanel.saveSettingsGroup.outputBitDepthDropDown;
        var outputBitDepthLabel = setupWindow.leftGroup.outputPanel.saveSettingsGroup.outputBitDepthLabel;
        var okButton = setupWindow.rightGroup.okButton;
        var cancelButton = setupWindow.rightGroup.cancelButton;
        var toningPanel = setupWindow.leftGroup.toningPanel;
        var deghostCheckBox = setupWindow.leftGroup.inputPanel.bracketGroup.deghostCheckBox;
        //set default values
        bracketBox.text = numberOfBrackets;
        filterText.text = fileMask;
        //mergeToHDR.useAlignment = true;
        alignCheckBox.value = mergeToHDR.useAlignment;
        deghostCheckBox.value = hdrDeghosting;
        outputFilenameText.text = outputFilename;
        jpegQualityText.text = jpegQuality;
        saveDropDown.add("item", "JPEG");
        saveDropDown.add("item", "TIFF");
        saveDropDown.add("item", "TIFF LZW");
        saveDropDown.add("item", "TIFF ZIP");
        saveDropDown.add("item", "PSD");
        saveDropDown.selection = 0;
        outputBitDepthDropDown.add("item", "8");
        outputBitDepthDropDown.add("item", "16");
        outputBitDepthDropDown.add("item", "32");
        outputBitDepthDropDown.selection = 0;
        //event handlers
        sourceBox.onChange = function()
            sourceFolder = new Folder(sourceBox.text);
            okButton.enabled = sourceFolder != null && outputFolder != null && sourceFolder.exists && outputFolder.exists;
        sourceBrowse.onClick = function()
            sourceFolder = Folder.selectDialog ("Select the source folder");
            if(sourceFolder != null)
                sourceBox.text = sourceFolder.fullName;
            okButton.enabled = sourceFolder != null && outputFolder != null && sourceFolder.exists && outputFolder.exists;
        bracketBox.onChange = function() { numberOfBrackets = bracketBox.text; };
        filterText.onChange = function() { fileMask = filterText.text; };
        alignCheckBox.onClick = function() { mergeToHDR.useAlignment = alignCheckBox.value; };
        deghostCheckBox.onClick = function() { hdrDeghosting = deghostCheckBox.value; };
        outputBox.onChange = function()
            outputFolder = new Folder(outputBox.text);
            okButton.enabled = sourceFolder != null && outputFolder != null && sourceFolder.exists && outputFolder.exists;
        outputBrowse.onClick = function()
            outputFolder = Folder.selectDialog ("Select the output folder");
            if(outputFolder != null)
                outputBox.text = outputFolder.fullName;
            okButton.enabled = sourceFolder != null && outputFolder != null && sourceFolder.exists && outputFolder.exists;
        outputFilenameText.onChange = function() { outputFilename = outputFilenameText.text; };
        saveDropDown.onChange = function()
            saveType = saveDropDown.selection.text;
            jpegQualityText.enabled = saveDropDown.selection.text == "JPEG";
            jpegQualityLabel.enabled = saveDropDown.selection.text == "JPEG";
            if(saveDropDown.selection.text == "JPEG")
                outputBitDepthDropDown.selection = 0;
            outputBitDepthDropDown.enabled = saveDropDown.selection.text != "JPEG";
            outputBitDepthLabel.enabled = saveDropDown.selection.text != "JPEG";
        jpegQualityText.onChange = function() { jpegQuality = jpegQualityText.text; };
        outputBitDepthDropDown.onChange = function()
            outputBitDepth = outputBitDepthDropDown.selection.text;
            toningPanel.enabled = outputBitDepth != 32;
        okButton.onClick = function() { setupWindow.hide(); cleanUpPreviews(); };
        cancelButton.onClick = function() { sourceFolder = null, setupWindow.hide(); cleanUpPreviews(); };
        saveDropDown.onChange();
        outputBitDepthDropDown.onChange();
        setupWindow.show();
    function cleanUpPreviews()
        if(originalDoc != null)
            originalDoc.close(SaveOptions.DONOTSAVECHANGES);
            originalDoc = null;
        if(previewDoc != null)
            previewDoc.close(SaveOptions.DONOTSAVECHANGES);
            previewDoc = null;
    function generateToningPanel(toningPanel)
        var leftToningGroup = toningPanel.add("group{orientation:'column',alignChildren:'fill'}");
        var rightToningGroup = toningPanel.add("group{orientation:'column',alignChildren:'fill'}");
        var presetGroup = leftToningGroup.add("group{orientation:'row'}");
        var presetDropDown = presetGroup.add("dropdownlist");
        var loadPresetButton = presetGroup.add("button", undefined, "Load Preset");
        var edgePanel = leftToningGroup.add("panel",undefined,"Edge Glow");
        var radiusSlider = createSliderControl(edgePanel.add("group"), "  Radius: ", "px", 0, 500, 0, hdrRadius, function(newValue){ hdrRadius = newValue; });
        var strengthSlider = createSliderControl(edgePanel.add("group"), "Strength: ", "", 0, 4.0, 2, hdrStrength, function(newValue){ hdrStrength = newValue; });
        var edgeGroup = edgePanel.add("group");
        var smoothEdgesBox = edgeGroup.add("checkbox",undefined, "Smooth Edges");
        var detailPanel = leftToningGroup.add("panel",undefined,"Tone and Detail");
        var gammaSlider = createSliderControl(detailPanel.add("group"), "  Gamma: ", "", 0.1, 2.0, 2, hdrGamma, function(newValue){ hdrGamma = newValue; });
        var exposureSlider = createSliderControl(detailPanel.add("group"), "Exposure: ", "", -5.0, 5.0, 2, hdrExposure, function(newValue){ hdrExposure = newValue; });
        var detailSlider = createSliderControl(detailPanel.add("group"), "     Detail: ", "%", -300, 300, 0, hdrDetail, function(newValue){ hdrDetail = newValue; });
        var advancedPanel = leftToningGroup.add("panel",undefined,"Advanced");
        var shadowSlider = createSliderControl(advancedPanel.add("group"), "  Shadow: ", "%", -100, 100, 0, hdrShadow, function(newValue){ hdrShadow = newValue; });
        var highlightSlider = createSliderControl(advancedPanel.add("group"), " Highlight: ", "%",  -100, 100, 0, hdrHighlights, function(newValue){ hdrHighlights = newValue; });
        var vibranceSlider = createSliderControl(advancedPanel.add("group"), "  Vibrance: ", "%",  -100, 100, 0, hdrVibrance, function(newValue){ hdrVibrance = newValue; });
        var saturationSlider = createSliderControl(advancedPanel.add("group"), "Saturation: ", "%",  -100, 100, 0, hdrSaturation, function(newValue){ hdrSaturation = newValue; });
        var toningCurvePanel = leftToningGroup.add("panel{text:'Toning Curve',alignChildren:'fill'}");
        var curveBox = toningCurvePanel.add("edittext", undefined, hdrCurve);
        //right side (preview panel)
        var previewGroup = rightToningGroup.add("panel", undefined, "Preview");
        var selectPreviewButton = previewGroup.add("button",undefined,"Select File(s)...");
        var previewButton = previewGroup.add("button",undefined,"Update Preview");
        var zoomGroup = previewGroup.add("group");
        zoomGroup.add("statictext",undefined, "zoom");
        var zoomBox = zoomGroup.add("edittext { text: '100', characters: 3, enabled: false } ");
        var previewZoomSlider = previewGroup.add("slider { minvalue: 10, maxvalue: 200, value: 100, enabled: false }");
        //default values
        smoothEdgesBox.value = hdrSmooth;
        previewButton.enabled = app.documents.length > 0;
        var presetFiles = getPresetFiles();
        var updateSliders = function()
            radiusSlider(hdrRadius);
            strengthSlider(hdrStrength);
            smoothEdgesBox.value = hdrSmooth;
            exposureSlider(hdrExposure);
            gammaSlider(hdrGamma);
            detailSlider(hdrDetail);
            shadowSlider(hdrShadow);
            highlightSlider(hdrHighlights);
            vibranceSlider(hdrVibrance);
            saturationSlider(hdrSaturation);
            curveBox.text = hdrCurve;
        if(presetFiles.length > 0)
            for(var f in presetFiles)
                presetDropDown.add("item", presetFiles[f].displayName.replace(".hdt",""));
            presetDropDown.selection = 0;
            loadPreset(presetFiles[0]);
            presetDropDown.onChange = function()
                loadPreset(presetFiles[presetDropDown.selection.index]);
                updateSliders();
        //event handlers
        loadPresetButton.onClick = function()
            loadPreset(null);
            updateSliders();
        smoothEdgesBox.onClick = function () { hdrSmooth = smoothEdgesBox.value; };
        curveBox.onChange = function () { hdrCurve = curveBox.text; };
        selectPreviewButton.onClick = function()
            var selectedFiles = File.openDialog("Select file(s) to load for preview", function(){return true;}, true);
            if(selectedFiles != null)
                cleanUpPreviews();
                if(selectedFiles instanceof Array)
                    if(selectedFiles.length > 1)
                        mergeToHDR.outputBitDepth= 32;
                        mergeToHDR.mergeFilesToHDR( selectedFiles, false, -2 );
                    else
                        doOpenFile(selectedFiles[0].fullName);
                else
                    doOpenFile(selectedFiles.fullName);
                originalDoc = app.activeDocument;
                previewButton.enabled = originalDoc != null;
                zoomBox.text = getZoomLevel();
                previewZoomSlider.value = getZoomLevel();
        previewButton.onClick = function()
            if(originalDoc != null)
                var tempOutputBitDepth = outputBitDepth;
                outputBitDepth = 16;
                if(previewDoc != null)
                    previewDoc.close(SaveOptions.DONOTSAVECHANGES);
                previewDoc = originalDoc.duplicate("HDR Preview");
                app.activeDocument = previewDoc;
                setZoomLevel(previewZoomSlider.value);
                convertTo32Bit();
                doHDRToning();
                outputBitDepth = tempOutputBitDepth;
                waitForRedraw();
                zoomBox.enabled = previewDoc != null;
                previewZoomSlider.enabled = previewDoc != null;
        zoomBox.onChange = function()
            if(previewDoc != null)
                previewZoomSlider.value = zoomBox.text;
                setZoomLevel(previewZoomSlider.value);
        previewZoomSlider.onChange = function()
            if(previewDoc != null)
                zoomBox.text = previewZoomSlider.value.toFixed(0);
                setZoomLevel(previewZoomSlider.value);
        updateSliders();
    function createSliderControl(group,label,postLabel,min,max,round,value,onValueChanged)
        var ignoreChange = false;
        group.add("statictext", undefined, label);
        var slider = group.add("slider",undefined,value,min,max);
        slider.alignment = "fill";
        var box = group.add("edittext",undefined,value);
        box.characters = 6;
        group.add("statictext", undefined, postLabel);
        slider.onChange = function()
            if(!ignoreChange)
                ignoreChange = true;
                box.text = slider.value.toFixed(round);
                onValueChanged(slider.value);
                ignoreChange = false;
        box.onChange = function()
            if(!ignoreChange)
                ignoreChange = true;
                slider.value = box.text;
                onValueChanged(box.text);
                ignoreChange = false;
        return function(newValue)
            slider.value = newValue;
            box.text = newValue.toFixed(round);
    //forces a redraw while a script dialog is active (for preview)
    var waitForRedraw = function()
        var desc = new ActionDescriptor();
        desc.putEnumerated(charIDToTypeID("Stte"), charIDToTypeID("Stte"), charIDToTypeID("RdCm"));
        executeAction(charIDToTypeID("Wait"), desc, DialogModes.NO);
    function getZoomLevel()
        var ref = new ActionReference();
        ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
        var desc = executeActionGet(ref);
        return Number(desc.getDouble(stringIDToTypeID('zoom'))*100).toFixed(1);
    function setZoomLevel( zoom )
        if(zoom < 1 ) zoom =1;
        var ref = new ActionReference();
        ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
        var getScrRes = executeActionGet(ref).getObjectValue(stringIDToTypeID('unitsPrefs')).getUnitDoubleValue(s tringIDToTypeID('newDocPresetScreenResolution'))/72;
        var docRes = activeDocument.resolution;
        activeDocument.resizeImage( undefined, undefined, getScrRes/(zoom/100), ResampleMethod.NONE );
        var desc = new ActionDescriptor();
        ref = null;
        ref = new ActionReference();
        ref.putEnumerated( charIDToTypeID( "Mn  " ), charIDToTypeID( "MnIt" ), charIDToTypeID( 'PrnS' ) );
        desc.putReference( charIDToTypeID( "null" ), ref );
        executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
        activeDocument.resizeImage( undefined, undefined, docRes, ResampleMethod.NONE );
    function ZeroPad(number,numZeros)
        var result = number.toString();
        while(result.length < numZeros)
            result = "0" + result;
        return result;
    var getPresetFiles = function()
        var presetFolder = new Folder(app.path + "/Presets/HDR Toning");
        return presetFolder.getFiles("*.hdt");
    var loadPreset = function(presetFile)
        if(presetFile == null)
            presetFile = File.openDialog("Select Preset","*.hdt");
        if(presetFile != null)
            var tmpStr = new String();
            var binaryData = new Array();
            presetFile.encoding = "BINARY";
            presetFile.open('r');
            while(!presetFile.eof)
                var ch = presetFile.readch();
                if ( ch.charCodeAt(0) == 0 ){
                    tmpStr += ' ';
                else {
                    tmpStr += ch;
                binaryData.push(ch.charCodeAt(0));
            presetFile.close();
            if(binaryData.length >= 40)
                // init start position for reading datas
                // start position for english version ( string "D e f a u l t" is in the preset file )
                var startPos = 38;
                if ( tmpStr.search ("P a r   d é f a u t") > -1 ){
                    // start position for french preset file version ( string "P a r   d é f a u t" is in the preset file ) (==> + 6 bytes)
                    startPos = 44;
                // if your preset file can't be read, try this : open it in notepad to see the string "D e f a u l t" in your language and add the code here to set startPos to 38 + diff between the length of ("D e f a u l t") and length of ("D e f a u l t" in your language)
                var curvePointCount = getUInt16(binaryData, startPos);
                if(binaryData.length >= 104 + curvePointCount * 4)
                    var curvePointStr = "";
                    for(var i = 0; i < curvePointCount; i++)
                        curvePointStr += getUInt16(binaryData, startPos + 4 + i * 4) + "," + getUInt16(binaryData, startPos + 2 + i * 4) + ((i < curvePointCount - 1) ? "," : "");
                    hdrCurve = curvePointStr;
                    hdrStrength =  getFloat32(binaryData,8);
                    hdrRadius = getFloat32(binaryData, startPos + 10 + 5 * curvePointCount);
                    hdrExposure = getFloat32(binaryData, startPos + 34 + 5 * curvePointCount);
                    hdrSaturation = getFloat32(binaryData, startPos + 38 + 5 * curvePointCount);
                    hdrDetail = getFloat32(binaryData, startPos + 42 + 5 * curvePointCount);
                    hdrShadow = getFloat32(binaryData, startPos + 46 + 5 * curvePointCount);
                    hdrHighlights = getFloat32(binaryData, startPos + 50 + 5 * curvePointCount);
                    hdrGamma = getFloat32(binaryData, startPos + 54 + 5 * curvePointCount);
                    hdrVibrance = getFloat32(binaryData, startPos + 58 + 5 * curvePointCount);
                    hdrSmooth = getUInt16(binaryData, startPos + 62 + 5 * curvePointCount) != 0;
                else
                    alert("Error Loading File", "Error", true);
            else
                alert("Error Loading File", "Error", true);
    function getUInt16(byteArray,offset)
        return byteArray[offset] * 0x100 + byteArray[offset + 1];
    function getUInt32(byteArray,offset)
        return byteArray[offset] * 0x1000000 + byteArray[offset + 1] * 0x10000 + byteArray[offset + 2] * 0x100 + byteArray[offset + 3];
    function getFloat32(byteArray,offset)
        var bytes = getUInt32(byteArray,offset);
        var sign = (bytes & 0x80000000) ? -1 : 1;
        var exponent = ((bytes >> 23) & 0xFF) - 127;
        var significand = (bytes & ~(-1 << 23));
        if (exponent == 128)
            return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY);
        if (exponent == -127) {
            if (significand == 0) return sign * 0.0;
            exponent = -126;
            significand /= (1 << 22);
        } else significand = (significand | (1 << 23)) / (1 << 23);
        return sign * significand * Math.pow(2, exponent);
    main();

  • Why is HDR merge in LR CC so s-l-o-w?

    Shot a 5 shot series, plus or minus 2, plus or minus 1 and normal with Olympus OM-D E-M1, off a tripod. The RAWs are "ORF" format.
    With Auto Align, Auto Contrast and deghosting turned off, it took about 90 seconds to get the preview up to merge. Merging in LR took another 45-60 seconds with virtually no "HDR" effect per se.
    Range of develop sliders is the same as if I had used Photoshop Merge to HDR Pro of left it in 32 bit TIFF so this DNG is probably a 32 bit image wrapped in a DNG format.
    Questions:
    Why does it take so long for the merging to take place as it doesn't seem that it's actually "tone-mapping," or is it?
    Resulting "hdr" image doesn't show great range compared either to 32 bit TIFFs from Merge to HDR Pro or from Photomatix 32 bit option.
    Aligning images increases preview generation even longer, making it almost unusable. Anyone else notice the same?
    I like LR very much but this implementation of supposed HDR seems to miss the mark badly.
    Comments??

    (Windows 7, i7-860 processor, 12 GB)
    Six (6) Canon 5D MKII CR2 21 Megagpixel raw files with 1.3 EV bracket
                                                    To Preview  Merge     Total Time
    LR CC 2015 Merge to HDR:      62 sec.     20 sec.      82 sec. 
    PS CC 2014 HDR Pro:              70 sec.     14 sec.      84 sec.
    (Using LR Edit In & 32 bit Mode)
    The two images as processed in LR Develop module look nearly identical. You need to crank up the -Highlights and +Shadows to achieve HDR recovery.
    Settings for the LR HDR DNG in the above example:

  • HDR Save as a JPEG

    Hello,
    I've been using the merge to HDR option in Camera Raw and tone mapping in Raw. Now after all of my hard work getting the image just right the only way Photoshop will allow me to save as a JPEG is by merging the layers to form an 8 Bit image. Doing this however opens up the HDR Toning dialogue box drastically changing the image, does this mean that it's impossible to save as a JPEG using the Merge to HDR function in Camera Raw, if so is there another way I can upload my image to the internet? Many thanks!

    The other way to do things is to set your Preferences / File Handling to have ACR do the 32-bit to 16/8-bit toning, and when you're exiting HDR Pro, just cancel out of the ACR dialog that comes up and then on your 32-bit layer, use Mode / 16- or 8-bit which will bring up ACR instead of the older HDR-Toning panel, and you can do the 32-bit to 8-bit conversion in ACR as a separate step.  Whether this method makes sense depends on what else you might be doing with the 32-bit layer in PS.  If nothing then using ACR to do the 32-bit to 16/8-bit conversion might make more sense.

  • Photomatix Pro HDR Plug-in Updated with additional Lightroom Functinality

    04-Feb 2009
    Update log
    Updated in v3.1.3
    - Tighter integration with Lightroom. HDR options are now set from the
    Lightroom plug-in and the processed image can be automatically re-imported
    into the Lightroom library.
    - Bug fixed: Processing files in Canon sRaw format caused an exception.
    - Bug fixed: Transfer of exif data was not always taking the information of
    the normal exposure.
    - Bug fixed: When tone mapping an HDR image file that was previously saved
    as Radiance in Photomatix Pro, the color profile was not properly embedded.
    - Bug fixed: When strip processing option had been enabled for HDR
    generation in batch processing, checking the blending methods at the same
    time made the batch return an error.
    - Bug fixed: Processing source images in the BMP format returned an error.
    Rikk

    >DaveBurns:CR - Can you help me understand where? I'm looking at the Plug-in Manager now with the Photomatix
    plug-in selected on the left. I don't see standard LR buttons to do those actions.
    That's because you're looking at the Photomatrix plugin, not one of Jeffrey's plug-ins :)
    I pointed to one of Jeffrey's plug-ins to show that one button updates can be performed for LR plug-ins. It is up to the author of the plug-in to include the update items that appear in the LR Plug-in manager and Photomatrix didn't provide that capability in their plug-in.

Maybe you are looking for

  • Cannot burn CDs after upgrade to iTunes 6.0.1.3

    I Can no longer burn CDs - Always get "unknown error 2122" Have updated: - optical drive firmware - audio driver - display adapter driver - Intel chipset software - CMOS BIOS Tried but cannot access update for my motherboard's ATA bus driver iTunes C

  • Problem connecting MacBook to a Sharp video projector

    One of the great things I like about Macs is the easy way they (usually) connect to a video projector. Unlike a lot of my friends who run PCs with Windows I never had any problems whatsoever connecting my MacBook to a projector at the university and

  • Different background color when loading applets

    I can't find the information for when a browser loads an applet, to change the background color while the applet is loading. I know there are other "optional" applet tags as well, but I can't find the information. Any help is appreciated.

  • How do I re-download MediaAccessibility.dll

    Everytime I download an update for iTunes it is a huge problem because something goes wrong and this time it's saying I'm missing MediaAccessibility.dll and I have to reinstall iTunes because it was installed incorrectly, although I've already redown

  • Creating Chapter Length

    I'm trying  to work with a video that is going to be used for ceremonial purposes.  On parts of it I need the video to hold on a certain image for minutes at a time.  Is there any way I can create a chapter where it's just the frozen image and it wil