Subscribe Bookmark RSS Feed

Open Local Image In Expression Column

robot

Community Trekker

Joined:

Feb 27, 2012

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

Staff

Joined:

Mar 21, 2013

Solution

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
5 REPLIES
Craige_Hales

Staff

Joined:

Mar 21, 2013

Solution

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

Community Trekker

Joined:

Feb 27, 2012

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

Staff

Joined:

Mar 21, 2013

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

Joined:

Jun 22, 2012

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

Community Trekker

Joined:

Feb 27, 2012

Thanks txnelson and Craige@JMP.  Both methods worked.