cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
robot
Level VI

Open Local Image In Expression Column

Hi,

I am trying to import some images into a data table using an Expression Column in JMP12.  I am able to import an image from URL, but when I try the same technique on a local image, JMP12 will open the image rather than import it into the data table.  Does anyone have any idea what is causing this difference how to resolve it?  Thanks!

Names Default To Here( 1 );

dt = New Table( "Image Test",

       Add Rows( 1 ),

       New Column( "Image from URL",

             Expression,

             Formula( New Image( Open( "http://eits.uga.edu/_resources/files/images/JMP_logo.png" ) ) )

       ),

       New Column( "Local Image",

             Expression,

             Formula( New Image( Open( "C:\Program Files\SAS\JMP\12\Samples\Images\tile.jpg" ) ) )

       ),

);

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: Open Local Image In Expression Column

add the type argument to the open function.

Formula( New Image( Open( "$desktop/circle.png", "png" ) ) )

it will probably work OK even if you mix'n'match png, jpg, gif because the 2nd argument is mostly telling open not to pass the file to the OS default program but to turn it into an image if possible.

Craige

View solution in original post

5 REPLIES 5
Craige_Hales
Super User

Re: Open Local Image In Expression Column

add the type argument to the open function.

Formula( New Image( Open( "$desktop/circle.png", "png" ) ) )

it will probably work OK even if you mix'n'match png, jpg, gif because the 2nd argument is mostly telling open not to pass the file to the OS default program but to turn it into an image if possible.

Craige
robot
Level VI

Re: Open Local Image In Expression Column

Thanks Craige@JMP.  That works.

One complication is that if I replace the <type> argument with a column reference, it seems to no longer work.  Do you know why?

Names Default To Here( 1 );

dt = New Table( "Image Test",

       Add Rows( 1 ),

       New Column( "Image Type", Character, Nominal, Set Values( {"png"} ) ),

       New Column( "Image from URL",

             Expression,

             Formula(

                    New Image( Open( "http://eits.uga.edu/_resources/files/images/JMP_logo.png", :Image Type ) )

             )

       ),

       New Column( "Local Image",

             Expression,

             Formula( New Image( Open( "$desktop/circle.png", :Image Type ) ) )

       )

);

Craige_Hales
Super User

Re: Open Local Image In Expression Column

I'm not where I can look at the JMP source, but it's possible it is being treated like a keyword and not a variable.  I'm pretty certain you can just use "png" even for a .jpg.

Craige
txnelson
Super User

Re: Open Local Image In Expression Column

try changing the formula to:

New Image( Open("http://cits.uga.edu/_resources/files/images/JMP-logo.png",Eval(Parse(char(:Image Type[Row()]) )) ) )

This should force the proper evaluation

Jim
robot
Level VI

Re: Open Local Image In Expression Column

Thanks txnelson and Craige@JMP.  Both methods worked.