cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
cchueng
Level III

Open and add 4 JPEGs into a 2x2 window

Hi,

How do I write a script to open 4 jpegs in JMP and then place them in a 2x2 window? I would like to specify the size of the window to be a certain size. Then I would like to save the window into a jpeg.

 

Any help is appriciated! Thanks!

2 REPLIES 2
txnelson
Super User

Re: Open and add 4 JPEGs into a 2x2 window

Here is a simple example of one way to handle the question

txnelson_0-1714788153213.png

Names Default To Here( 1 );

image1 = New Image( "$SAMPLE_IMAGES/windmap.png" );
image2 = New Image( "$SAMPLE_IMAGES/black rhino footprint.jpg" );
image3 = New Image( "$SAMPLE_IMAGES/tile.jpg" );
image4 = New Image( "$SAMPLE_IMAGES/pi.gif" );

nw = New Window( "Pictures",
	Outline Box( "The Pictures",
		Lineup Box( N Col( 2 ), image1, image2, image3, image4 )
	)
);

theWholePicture = nw[Outline Box( 1 )] << get picture;

theWholePicture << save image( "$TEMP/myPicture.jpg,", "jpg" );

nw << close window;

theSavedImage = New Image( "$TEMP/myPicture.jpg," );

theNW = New Window( "Final Picture", theSavedImage );

You can set the images sizes by using

img << Set Size( {600, 600} );

See the Scripting Index for the messages that can be used with New Image

Jim
jthi
Super User

Re: Open and add 4 JPEGs into a 2x2 window

I would go with the Lineup box like Jim did show as I think it is the simplest option. One other option (more complicated) is to use Graph Box and add images to it

 

Names Default To Here(1);

image1 = New Image("$SAMPLE_IMAGES/windmap.png");
image2 = New Image("$SAMPLE_IMAGES/black rhino footprint.jpg");
image3 = New Image("$SAMPLE_IMAGES/tile.jpg");
image4 = New Image("$SAMPLE_IMAGES/pi.gif");

nw = New Window("View Image",
	gb = Graph Box(
		FrameSize(500, 500),
		X Scale(0, 100),
		Y Scale(0, 100),
		SuppressAxes(1)
	)
);

fb = nw[FrameBox(1)];

fb << Add Image(image(image1), bounds(top(0), Left(0), bottom(50), Right(50)));
fb << Add Image(image(image2), bounds(top(0), Left(50), bottom(50), Right(100)));
fb << Add Image(image(image3), bounds(top(100), Left(0), bottom(50), Right(50)));
fb << Add Image(image(image4), bounds(top(100), Left(50), bottom(50), Right(100)));

img = fb << get picture;
img << save image("$TEMP/pic.png", "png");
nw << close window;

 

At least one more technique can be found from this post Merging/stitching images 

-Jarmo