MATLAB Answers

opening a .bmp with photoshop

3 views (last 30 days)
There is a .bmp file in directory c:\folder\mm.bmp. I want to open it with photoshop from inside of MATLAB with command. Any idea?


Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 4 Aug 2012
Use this code. Adapt it to reflect the actual filename of your image and your Photoshop location.
% Get the name of the image file. Get the full filename, with path prepended.
% Use a standard MATLAB color demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'peppers.png';
% Get the full filename, with path prepended.
fullImageFileName = fullfile(folder, baseFileName);
if ~exist(fullImageFileName, 'file')
% Didn't find image. Alert user.
errorMessage = sprintf('Error: image\n%s\ndoes not exist.', fullImageFileName);
% Check to see that Photoshop executable exists.
editorFullFileName = 'C:\Program Files\Adobe\Adobe Photoshop CS5 (64 Bit)\Photoshop.exe';
if ~exist(editorFullFileName, 'file')
errorMessage = sprintf('Cannot find the Photoshop program.\n%s', editorFullFileName);
% Now run the Photoshop program, passing in the image filename.
% First construct the command line for the system() function.
% Enclose all filenames in double quotes because we may have spaces in the filenames.
arguments = sprintf('"%s"', fullImageFileName);
commandLine = sprintf('"%s" %s', editorFullFileName, arguments);
fprintf('%s', commandLine);
% Now launch the Photoshop program using the "system()" function.


Show 2 older comments
Image Analyst
Image Analyst on 4 Aug 2012
That is correct. But in general, your pathOFfile would be "arguments" - a list of whatever arguments that program takes in via the command line. The command line could be filenames or switches/options starting with a dash or slash. In fact I modified the above from code where I was using a program I wrote in Visual Studio that took two files and some option switches via the command line.
mohammad on 4 Aug 2012
So great !!! Really thanks Image Analyst.
Image Analyst
Image Analyst on 9 Jan 2014
You can also try Jeff's utility to read Photoshop PSD files from MATLAB:

Sign in to comment.

More Answers (0)

Sign in to answer this question.