Unable to get file name when loading NEF (RAW) Pics

Moderator: Kathy_9

Promethiusn
Posts: 4
Joined: Thu Mar 05, 2020 6:16 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
Corel programs: X8, X9, 2019

Unable to get file name when loading NEF (RAW) Pics

Post by Promethiusn »

A script I have been writing uses a file save at midpoint of the script. It works fine with .JPG files, either loaded directly into PSP X9 or exported from Lightroom, but NEF files brought in through the RAW Lab crash when running FileSAve. The file path\name does not exist. I am also unable to get file title. Printing App.ActiveDocument.Title and App.TargetDocument.Name shows nothing, although I can append to another variable plus text to them just to make something show up. The filesave is a recorded script. The file name shows up on the tab, and if I first save the file and then run the script it works fine. I haven't ran this in PSP 2019. I can work around by simply saving the file before the script is ran, but it is one of those things that I would like to fix. Is this a bug/normal behavior for X9, or is it something I can code differently? I appreciate any input on this.

Code: Select all

      # FileSave before adding borders and watermark
    App.Do( Environment, 'FileSave', {
            'Encoding': {
                'JPG': {
                    'Variant': App.Constants.JpegFormat.Lossless, 
                    'CompressionFactor': 1, 
                    'ChromaSubSampling': App.Constants.ChromaSubSampling.YCC_1x1_1x1_1x1, 
                    'EXIF': True, 
                    'EmbedJPGICC': True
                    }
                },
            'FileName': u'' + App.TargetDocument.Name,
            'FileFormat': App.Constants.FileFormat.JPG, 
            'WorkingMode': 0, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.AllAlways, 
                'Version': ((19,0,0),1)
                }, 
            'DefaultProperties': []
            })
            
 
LeviFiction
Advisor
Posts: 6472
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: Unable to get file name when loading NEF (RAW) Pics

Post by LeviFiction »

It's normal behavior. RAW LAB imports the photo as a new image so it literally only exists in memory at that point.

If you want the .Name member of either the Target or Active Document objects to be a file path you cannot use RAW LAB. If you go to File -> Preferences -> File Format Preferences and uncheck "Use RAW Lab for RAW files" then RAW LAB won't open and it'll give you your full file path. Or if you make sure to always export RAW files from Lightroom or other RAW editor then that will also be your best bet.

Other options include
1 - Use a simple conditional to check if a Name exists. If no name exists use SaveAs.
2 - Use option #1 but if it was the last file you opened before running the script you can use some code to get the folder location to inform your file naming to use SaveAs non-interactively in any format you want.

Code: Select all

if App.TargetDocument.Name == '':
    SaveFolder = App.Do(Environment, 'GetCommandInfo', {'TargetCmd':'FileOpen', 'LastUsed':True})['CmdFile\\FileOpen']['Folder']
    SaveExtension = ".PNG"
    FileName = SaveFolder + "\\" + App.ActiveDocument.Title + SaveExtension
    # SaveAs with Filename above and default settings for format chosen.  In this example PNG
3 - If you want you can use TKInter UI library to use your own FileOpen dialog and get the filename that was returned. Then you can choose how to react similar to the above based on the file type. Knowing that the image will be imported via RAW Lab. But you'll know for certain what the original filename was.
User avatar
fs999
Posts: 78
Joined: Thu Jul 21, 2011 9:55 pm
operating_system: Windows 10
System_Drive: Z
32bit or 64bit: 64 Bit
motherboard: Intel
processor: i7 860
ram: 32GB
Video Card: NVIDIA GeForce GTX 730
sound_card: Samsung HDMI
Hard_Drive_Capacity: 28 TB
Monitor/Display Make & Model: Philips 24P4 & Samsung UE46M6050
Corel programs: PaintShop 2020 Ultimate

Re: Unable to get file name when loading NEF (RAW) Pics

Post by fs999 »

I use a little trick to load raw files with their name.

1. in Manage I check "Open RAW images with Camera RAW" in File Format Preferences.
2. I right click the Raw image and choose "Edit RAW" which opens the Camera RAW Lab window.
3. I adjust the image(s) like I want. And I click OK.
4. I uncheck "Open RAW images with Camera RAW" in File Format Preferences.
5. I right click the Raw image and choose "Edit RAW" which changes to Edit and opens the RAW image like I want with the name in the title.

It would be nice to have a menu (in Manage and Edit) to open Camera RAW Lab by right clicking the image, without having to check and uncheck the option...
Promethiusn
Posts: 4
Joined: Thu Mar 05, 2020 6:16 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
Corel programs: X8, X9, 2019

Re: Unable to get file name when loading NEF (RAW) Pics

Post by Promethiusn »

Thank you on the quick replies for this. Being able to see the file name on PSP's tab after it came through RAW Lab, and not being able to grab it was making me wonder. I use Lightroom probably 99% of the time and output the pics into PSP as .JPG. It was just the fraction of time that I loaded the RAW file straight in that was giving me problems.