<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: crop image and store into new column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/crop-image-and-store-into-new-column/m-p/869170#M103204</link>
    <description>&lt;P&gt;Unfortunately, with my actual data set, just some of the images got cropped.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The easy explanation:&amp;nbsp; I filled the image column&amp;nbsp; via copy / paste from a Powerpoint presentation.&lt;BR /&gt;All the images had the same aspect ratio, therefore they had the same size in the JMP data grid -&amp;nbsp; but they did not have the same actual size! And crop just works if the pixel values in the arguments are smaller than the actual size of the image.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Much easier to detect, when you use images with different aspect ratios ( trying to create a demo case for a community post ).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1744969643296.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/74999i1D6AB8795DD33A44/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_0-1744969643296.png" alt="hogi_0-1744969643296.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Open( "$SAMPLE_DATA/SAS Offices.jmp" );
New Column( "cropped", Expression);

for each row( img= new image(:Photo);
{w, h} = img &amp;lt;&amp;lt; Get Size;

img  &amp;lt;&amp;lt;   Crop( Left( 10 ), Right( 800 ), Top( 10 ), Bottom( 70 ) );:cropped = img)&lt;/CODE&gt;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;BR /&gt;so, my final script was:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Open( "$SAMPLE_DATA/SAS Offices.jmp" );
New Column( "cropped", Expression );

For Each Row(
	try(img = New Image( :Photo );
	{w, h} = img &amp;lt;&amp;lt; Get Size;
	target = 500;
	img &amp;lt;&amp;lt; scale( 500 / w );
	{w, h} = img &amp;lt;&amp;lt; Get Size;
	img &amp;lt;&amp;lt; Crop( Left( Round( w / 3 ) ), Right( Round( w / 3 * 2 ) ), Top( Round( h / 10 ) ), Bottom( Round( h / 5 ) ) );
	:cropped = img;)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Try? -&amp;gt; just in case one of the images is missing.&lt;/P&gt;</description>
    <pubDate>Sun, 04 May 2025 16:56:40 GMT</pubDate>
    <dc:creator>hogi</dc:creator>
    <dc:date>2025-05-04T16:56:40Z</dc:date>
    <item>
      <title>crop image and store into new column</title>
      <link>https://community.jmp.com/t5/Discussions/crop-image-and-store-into-new-column/m-p/869159#M103203</link>
      <description>&lt;P&gt;I wanted to crop images and store the cropped images in a new column.&lt;BR /&gt;&lt;BR /&gt;My first approach was:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;for each row (:new col = :old col &amp;lt;&amp;lt; crop(...))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;... but then I found &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/982"&gt;@Craige_Hales&lt;/a&gt;&amp;nbsp;post in the the community,&lt;BR /&gt;&lt;A href="https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442473/highlight/true#M69072" target="_blank" rel="noopener"&gt;https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442473/highlight/true#M69072&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;with the important information:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_1-1744966224479.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/74995iC52FF30E4F553016/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_1-1744966224479.png" alt="hogi_1-1744966224479.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;So, I tried this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
for each row (:pet = :picture );
wait(0);
for each row (:pet &amp;lt;&amp;lt;  Crop( Left( 5 ), Right( 10 ), Top( 6 ), Bottom( 100 ) ));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;... without effect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the Scripting Index, I found:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_2-1744967075102.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/74996i890DD0A32AA65E10/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_2-1744967075102.png" alt="hogi_2-1744967075102.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Maybe use &lt;FONT face="courier new,courier"&gt;img&lt;/FONT&gt; as a temporary variable?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
for each row( img= :picture;;img  &amp;lt;&amp;lt;   Crop( Left( 5 ), Right( 70 ), Top( 30 ), Bottom( 50 ) );:pet = img)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and indeed:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_3-1744967420011.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/74997i80A472DA335C3603/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_3-1744967420011.png" alt="hogi_3-1744967420011.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;But after clicking into the data table, I noticed that the input column was changed as well:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_4-1744967455266.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/74998i1EC20F2200AC1EEC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_4-1744967455266.png" alt="hogi_4-1744967455266.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;so, my final script was:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
for each row( img= new image(:picture);img  &amp;lt;&amp;lt;   Crop( Left( 5 ), Right( 70 ), Top( 30 ), Bottom( 50 ) );:pet = img)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;UL&gt;
&lt;LI&gt;use &lt;FONT face="courier new,courier"&gt;new image()&lt;/FONT&gt; to create a new image&lt;/LI&gt;
&lt;LI&gt;resize this image&lt;/LI&gt;
&lt;LI&gt;store it in the new column&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 18 Apr 2025 09:50:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/crop-image-and-store-into-new-column/m-p/869159#M103203</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-04-18T09:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: crop image and store into new column</title>
      <link>https://community.jmp.com/t5/Discussions/crop-image-and-store-into-new-column/m-p/869170#M103204</link>
      <description>&lt;P&gt;Unfortunately, with my actual data set, just some of the images got cropped.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The easy explanation:&amp;nbsp; I filled the image column&amp;nbsp; via copy / paste from a Powerpoint presentation.&lt;BR /&gt;All the images had the same aspect ratio, therefore they had the same size in the JMP data grid -&amp;nbsp; but they did not have the same actual size! And crop just works if the pixel values in the arguments are smaller than the actual size of the image.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Much easier to detect, when you use images with different aspect ratios ( trying to create a demo case for a community post ).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1744969643296.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/74999i1D6AB8795DD33A44/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_0-1744969643296.png" alt="hogi_0-1744969643296.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Open( "$SAMPLE_DATA/SAS Offices.jmp" );
New Column( "cropped", Expression);

for each row( img= new image(:Photo);
{w, h} = img &amp;lt;&amp;lt; Get Size;

img  &amp;lt;&amp;lt;   Crop( Left( 10 ), Right( 800 ), Top( 10 ), Bottom( 70 ) );:cropped = img)&lt;/CODE&gt;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;BR /&gt;so, my final script was:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Open( "$SAMPLE_DATA/SAS Offices.jmp" );
New Column( "cropped", Expression );

For Each Row(
	try(img = New Image( :Photo );
	{w, h} = img &amp;lt;&amp;lt; Get Size;
	target = 500;
	img &amp;lt;&amp;lt; scale( 500 / w );
	{w, h} = img &amp;lt;&amp;lt; Get Size;
	img &amp;lt;&amp;lt; Crop( Left( Round( w / 3 ) ), Right( Round( w / 3 * 2 ) ), Top( Round( h / 10 ) ), Bottom( Round( h / 5 ) ) );
	:cropped = img;)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Try? -&amp;gt; just in case one of the images is missing.&lt;/P&gt;</description>
      <pubDate>Sun, 04 May 2025 16:56:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/crop-image-and-store-into-new-column/m-p/869170#M103204</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-05-04T16:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: crop image and store into new column</title>
      <link>https://community.jmp.com/t5/Discussions/crop-image-and-store-into-new-column/m-p/869171#M103205</link>
      <description>&lt;P class="_tgt transPara grammarSection"&gt;&lt;SPAN class="transSent" data-group="0-0"&gt;This is not difficult.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="_tgt transPara grammarSection"&gt;&lt;SPAN class="transSent" data-group="1-0"&gt;I think the difficult part is: making the background of one picture transparent and superimposing it on other pictures.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="_tgt transPara grammarSection"&gt;&lt;SPAN class="transSent" data-group="2-0"&gt;JSL does not have the function of making the background of pictures transparent.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="_tgt transPara grammarSection"&gt;&lt;SPAN class="transSent" data-group="3-0"&gt;It can only be achieved with the assistance of other software&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Apr 2025 10:17:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/crop-image-and-store-into-new-column/m-p/869171#M103205</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2025-04-18T10:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: crop image and store into new column</title>
      <link>https://community.jmp.com/t5/Discussions/crop-image-and-store-into-new-column/m-p/869173#M103206</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;run program(executable("I:\00\FastStoneIV\magick.exe"),options({目||" -fill none -fuzz 0% -draw \!"color 92,30 floodfill\!" "||标}));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2025-04-18_18-22-01.png" style="width: 491px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/75000i0CF5662C15760C44/image-size/large?v=v2&amp;amp;px=999" role="button" title="2025-04-18_18-22-01.png" alt="2025-04-18_18-22-01.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Apr 2025 10:24:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/crop-image-and-store-into-new-column/m-p/869173#M103206</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2025-04-18T10:24:41Z</dc:date>
    </item>
  </channel>
</rss>

