• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Open custom RAW files

New Here ,
May 03, 2010 May 03, 2010

Copy link to clipboard

Copied

Hi there,

I do write my own RAW files, where the image data is somewhere in the middle of the file.

How can I tell Photoshop to open the file with my specific raw file options (which are normally specified in the Photoshop Raw Options dialog). Parameters like width, height, header...

It would be perfect to tell those parameters via command line or script from outside of Photoshop, so that I can handle different types of my custom RAW files.

Thanks,

Stefan

TOPICS
Actions and scripting

Views

3.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , May 05, 2010 May 05, 2010

Here is a javascript example

var rawFile = new File('~/Desktop/_SLP7637.raw');
var opts = new RawFormatOpenOptions();
opts.bitsPerChannel = 8;// or 16
//opts.byteOrder = ByteOrder.IBM; // only needed with bitsPerChannel is 16
opts.channelNumber = 3;
opts.headerSize = 0;
opts.height = 1008;// in pixels
opts.interleaveChannels = true;
//opts.retainHeader =  false;// only needed if headerSize is greater than 0
opts.width = 792;// in pixels

app.open( rawFile, opts );// open file reference with options

Votes

Translate

Translate
Adobe
Adobe Employee ,
May 04, 2010 May 04, 2010

Copy link to clipboard

Copied

You might try the Photoshop scripting forum for a better answer. Yes, you can tell Photoshop to open your camera file via ACR with specific settings. Part of your Photoshop install came with a ScriptListener plug-in. You can find it in <Photoshop>/Scripting/Utilities copy that plug-in into your Plug-Ins folder (or make a shortcut/alias). Restart Photoshop. Open your file and adjust it accordingly in ACR dialog. Notice that a ScriptListenerJS.log file is created on your desktop. Copy that file and delete it. Now open the same file again in Photoshop and make one minor adjustment to it. Compare the two log files and you should be able to find the minor adjustment made. You can also see that ACR has lots of settings. Some are easy enough to understand from the code in the log file and some are not. Keep making minor changes until you see what you are looking for.

If you have more questions I would pose them in the "Photoshop scripting" forum instead.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 04, 2010 May 04, 2010

Copy link to clipboard

Copied

Hi Tom,

thanks for your reply, that already helped me.

Now, there are two issues left:

1) I do not adjust the open parameters in the ACR dialog, but in the "Photoshop Raw Options" dialog. That settings are obviously not stored in the created logs on the desktop.

2) If the log is finally created, how do I tell Photoshop to open with this script?

Sorry for that noob questions.

If you think this discussion is better located in the Scripting forum, maybe an admin can move it?

Thanks,

Stefan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 05, 2010 May 05, 2010

Copy link to clipboard

Copied

Stefan, you are already posted in the suggested forum space…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 05, 2010 May 05, 2010

Copy link to clipboard

Copied

In javascript you can use RawFormatOpenOptions to set the open options without using scriptlistener.

VB and VBS should have something similar and can be run outside Photoshop.

It allows you to set bitsPerChannel, byteOrde, channelNumber, headerSize, height, interleaveChannels, retainHeader, and width.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 05, 2010 May 05, 2010

Copy link to clipboard

Copied

Michael, that is exactly what I need.

Is there some expert out there who could write me those few lines of code, using the RawFormatOpenOptions to open a file?

Language does not matter (javascript, VB...).

No other actions would be required, just to open a file with parameters, I would be able to specify.

That would be great and I would really appreciate it.

Thanks to all you guys for helping me so far.


Regards,

Stefan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 05, 2010 May 05, 2010

Copy link to clipboard

Copied

Here is a javascript example

var rawFile = new File('~/Desktop/_SLP7637.raw');
var opts = new RawFormatOpenOptions();
opts.bitsPerChannel = 8;// or 16
//opts.byteOrder = ByteOrder.IBM; // only needed with bitsPerChannel is 16
opts.channelNumber = 3;
opts.headerSize = 0;
opts.height = 1008;// in pixels
opts.interleaveChannels = true;
//opts.retainHeader =  false;// only needed if headerSize is greater than 0
opts.width = 792;// in pixels

app.open( rawFile, opts );// open file reference with options

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 05, 2010 May 05, 2010

Copy link to clipboard

Copied

Michael, the script works perfectly.

Thanks to you (and all others) for the help!

Regards,

Stefan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2010 May 13, 2010

Copy link to clipboard

Copied

Michael, can you help me out?  I was trying to use the code you supplied with a few modifications (path and values only) and got "Error 1233: Expected a reference to existing File/Floder."  I'm guessing the path to my photo isn't correct, but I can't for the life of me figure out why.  All the examples I see online are Linux/Mac which has a different file structure, so that doesn't help.

System: Windows XP, fully updated with patches

var rawFile = new File('C:\Documents and Settings\jim\Desktop\image.raw');
var opts = new RawFormatOpenOptions();
opts.bitsPerChannel = 16;
opts.byteOrder = ByteOrder.IBM; // only needed with bitsPerChannel is 16
opts.channelNumber = 1;
opts.headerSize = 0;
opts.height = 1439;
opts.interleaveChannels = false;
opts.retainHeader =  false;// only needed if headerSize is greater than 0
opts.width = 619;

app.open( rawFile, opts );// open file reference with options

I've tried:

  signle quotes around the path

  double quotes around the path

  putting the image at C:\image.raw to avoid spaces in the path

Is there some path in photoshop I need to set?

Thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
May 13, 2010 May 13, 2010

Copy link to clipboard

Copied

var rawFile = new File('C:\Documents and Settings\jim\Desktop\image.raw');

should be

var rawFile = new File('C:\\Documents and Settings\\jim\\Desktop\\image.raw');

or

var rawFile = new File('/c/Documents and Settings/jim/Desktop/image.raw');

or

var rawFile = new File(Folder.desktop + '/image.raw');

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 13, 2010 May 13, 2010

Copy link to clipboard

Copied

Any of Xbytor's suggestions would work. But to help explain why I will add that the backspace char is used in javascript as an escape char. For example \r is used for the new line char in a string. So if you need to have a backspace char itself in a string you need to escape it if that makes sense. Thus the double backspaces.

Also the forward slash notation is not really a Mac/linux thing. In javascript it is call an Uniform Resource Identifier or URI. And URI works on Windows as well as Mac. So even though '/c/Documents and Settings/jim/Desktop/image.raw' looks like a Mac path, in javascript it's a it's a valid path on Windows.

I made the same mistake when I started scripting Photoshop and X was also the one who told me what I was doing wrong.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 14, 2010 May 14, 2010

Copy link to clipboard

Copied

Thanks for the help.  I tried it and an now getting a new error "You must specify width, height, number of channels, interleae channels, and bits per channel when opening a raw image."  I thought that's what opts was doing.

1) Why doesn't it work?

2) Is there a good documentation site? (something like javadocs or the many good c++ sites when I can look up functions and their parameters)

3) What is "Folder?"  As in Folder.desktop.  It worked, but I don't know why or if I can do other stuff like Folder.mydocuments.

Thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 14, 2010 May 14, 2010

Copy link to clipboard

Copied

Yes opts should be setting the needed open options for a Photoshop Raw file. I'm not sure why you are getting that error message if the options are set.

For javascript, you can find the javascript reference in a subfolder where Photoshop is installed. You might also want to look at the javascript tools guide. It's in a subfolder where ExtendScript Toolkit is installed. Aldo ESKT has an object browser.

Folder is an ExtendScript class. Folder.desktop will return a Folder object for the desktop on either Win or Mac. Folder.myDocuments returns a object for the user documents. There is also Folder.temp, Folder.trash, and others. Note those are class properties. A Folder instance will have different properties.

Some times the error message is not too helpful. Are you sure the file you are using is a Photoshop Raw file? ( not camera raw )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 14, 2010 May 14, 2010

Copy link to clipboard

Copied

It is a camera RAW, not a photoshop RAW.  I didn't think it would make a difference as long as I specified the header size and other RAW options.  Are you saying that I cannot use camera raw images in this manor?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 14, 2010 May 14, 2010

Copy link to clipboard

Copied

For camera raw you need to use the CameraRAWOpenOptions. The javascript reference will have a list of those options. It's a long list of options but doesn't cover everything ACR does. You can open the file using the ACR dialog with this function.

function OpenCameraRaw(file) {
     try{
          var desc = new ActionDescriptor();
          desc.putPath(charIDToTypeID('null'), File(file.toString()));
          // Suppress choose file dialog.
          var overrideOpenID = stringIDToTypeID('overrideOpen');
          desc.putBoolean(overrideOpenID, true );
          var desc1 = new ActionDescriptor();
          desc.putObject( charIDToTypeID( 'As  ' ), stringIDToTypeID( 'Adobe Camera Raw' ), desc1 );
          var returnDesc = executeAction(charIDToTypeID('Opn '), desc, DialogModes.ALL);
          return (returnDesc.hasKey(charIDToTypeID('As  ')) && returnDesc.hasKey(charIDToTypeID('null')));
     }catch(e){}
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 24, 2010 May 24, 2010

Copy link to clipboard

Copied

Michael, unless I am missing something doesn't that function you posted just return a 0/1 (false/true) as to if the file was opened?  I assumed the image is in the returnDesc object, but I've looked through the ActionDescriptor object info and I can't find a way to get to the image.  Also, isn't everything out of scope when I return from the function (like in C/C++)?

Thanks for your help everyone.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 24, 2010 May 24, 2010

Copy link to clipboard

Copied

The function doesn't return a file or document object. It takes a file object as the argument and uses that to open the file in Photoshop. The activeDocument will be the document from that file if you are looking for a reference to the file/doc.

Yes anything defined in the function is out of scope outside of the function. I don't really remember now but I think if it returns true the raw file had settings. A return of false means ACR defaults were used.

I guess that if you don't care about the settings you could return app.activeDocument to have the function return a doc reference.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 02, 2010 Jun 02, 2010

Copy link to clipboard

Copied

I am trying to use the OpenCameraRaw function supplied by Michael, but am getting two "Illegal Argument" errors as shown in the code below.  I know it's those two lines because I see "On line 8" and then ""In OpenCameraRaw catch block Error: Illegal Argument".  When I comment out the "putObject" line I see the same this except I see "On line 9" before the exception. Any thoughts?

Also, is there any easy way to print the contents of variables or useful status messages?  The best I've been able to come up with is using Folder.selectDialog() as shown below.

function OpenCameraRaw(file) {
     try{
          var desc = new ActionDescriptor();
          desc.putPath(charIDToTypeID('null'), File(file.toString()));
          // Suppress choose file dialog.
          var overrideOpenID = stringIDToTypeID('overrideOpen');
          desc.putBoolean(overrideOpenID, true );
          var desc1 = new ActionDescriptor();
          var tmp = Folder.selectDialog("On line 8");
          desc.putObject( charIDToTypeID( 'As  ' ), stringIDToTypeID( 'Adobe Camera Raw' ), desc1 ); - Error: Illegal Argument
          var tmp = Folder.selectDialog("On line 9");
          var returnDesc = executeAction(charIDToTypeID('Opn '), desc, DialogModes.ALL); - Error: Illegal Argument
          var tmp = Folder.selectDialog("On line 10");
          return app.ActiveDocument;
     }catch(e){
         alert("In OpenCameraRaw catch block" + e);
     }
}

I don't know if this will help at all, but the image I am using is generated by an x-ray machine and is some weird image format with a 25B header that is only used by the medical community.  I don't know if being a non-standard image type and not a camera or photoshop raw will prevent me from progressing any further with the image.

Thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 02, 2010 Jun 02, 2010

Copy link to clipboard

Copied

Also, on the line

var returnDesc = executeAction(charIDToTypeID('Opn '), desc,  DialogModes.ALL);

I was wondering why you had 'Opn' and not 'Open'.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 03, 2010 Jun 03, 2010

Copy link to clipboard

Copied

I've been looking over the code and realized all the charIDToTypeID()'s should be stringIDToTypeID()'s and that has gotten me a little further.  I'm now getting the error "The command '<unknown>' is not currenty available."  I'm going to continue to look around and see what I can find, but any help is appreciated.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 03, 2010 Jun 03, 2010

Copy link to clipboard

Copied

Ok, I think that several things are going on here so that your code isn't working.

The main thing is you are using the wrong function. This thread started out about opening a PhotoshopRaw file and someone posted a question about a CameraRaw file. The function you are using is for the camera raw. It sounds like that is not the type of file you want to open.

Also it looks like your are trying to select the file to open inside the function. It would be better to do that outside then pass the fileref as an agrument.

I used charIDToTypeID('Opn ' ) because 'Opn ' is a charID. 'open' is a stringID. The reason your function is not working has nothing to do with which ID you are using so you didn't need to change the charIDs to stringIDs.

You can tell Photoshop the size of the header with the PhotoshopRaw open options so I don't think that is the problem either. If you review this thread you will find the fuction that opens PhotoshopRaw files. Try using that one. Or post height, width, header,etc and I will post an example of using that function with the settings you need.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 03, 2010 Jun 03, 2010

Copy link to clipboard

Copied

LATEST

PhotoNewbieNoob wrote:

I don't know if this will help at all, but the image I am using is generated by an x-ray machine and is some weird image format with a 25B header that is only used by the medical community.  I don't know if being a non-standard image type and not a camera or photoshop raw will prevent me from progressing any further with the image.

Thank you.

I missed that part of your post. If it is from an x-ray machine it might be a dicom file which the Extended versons of Photoshop should open.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
May 14, 2010 May 14, 2010

Copy link to clipboard

Copied

Camera RAW (bayer mosaic sensor data) and Photoshop RAW (just a raster bit dump) are two very different things.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines