<?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 a JPG Image in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442121#M69033</link>
    <description>&lt;P&gt;Nice job. The Right and Bottom definitions you provided are not exactly as you specified. Your script is spot on!&lt;/P&gt;
&lt;P&gt;See the script below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
img = Open( "$SAMPLE_IMAGES/tile.jpg", jpg );

s = {w,h} = img &amp;lt;&amp;lt; get size();
show( s ); //{451, 451}
obj = New Window( "tile(40,40)", img );
Wait( 1 );
img &amp;lt;&amp;lt; Crop( Left( 50 ), Right( 100 ), Top( 60 ), Bottom( 150 ) );
s = {w,h} = img &amp;lt;&amp;lt; get size();
show( s ); //{50, 90}

//img is a matrix of pixels the initail size is 1 to 451 columns aka "w" width
//and "h" is height 1 to 451 rows

//Crop Left(x) is the starting column and Right(y) is the ending column 
//Top() and Bottom() works the same, so after the crop the width is 100-50=50
//and the height is  150-60=90&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 03 Dec 2021 09:20:12 GMT</pubDate>
    <dc:creator>gzmorgan0</dc:creator>
    <dc:date>2021-12-03T09:20:12Z</dc:date>
    <item>
      <title>Crop a JPG Image</title>
      <link>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/441835#M69013</link>
      <description>&lt;P&gt;Trying to crop the light grey border from around the outside of the below wafermap image using the following script. I guess I'm not understanding how the crop message works as there is no difference in the before and after images.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea of what I'm doing wrong?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers, Troy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;img = open("D:\wafer.jpg", jpg);
win1 = newWindow("Original", img);

img &amp;lt;&amp;lt; crop(left(5),right(5),top(5),bottom(5));
win2 = newWindow("Cropped", img);

img &amp;lt;&amp;lt; savePicture("D:\waferCropped.jpg", jpg);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="thickey_0-1638495807241.png" style="width: 821px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38117i1BC22C62C5A11AFB/image-dimensions/821x472?v=v2" width="821" height="472" role="button" title="thickey_0-1638495807241.png" alt="thickey_0-1638495807241.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:06:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/441835#M69013</guid>
      <dc:creator>thickey</dc:creator>
      <dc:date>2023-06-09T18:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Crop a JPG Image</title>
      <link>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/441990#M69019</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I think that you forgot to assign the cropped image to a variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;img2 = img &amp;lt;&amp;lt; crop(left(5),right(5),top(5),bottom(5));
win2 = newWindow("Cropped", img2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;TS&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 06:05:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/441990#M69019</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2021-12-03T06:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Crop a JPG Image</title>
      <link>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442072#M69026</link>
      <description>&lt;P&gt;Thanks for the reply Thierry.&lt;/P&gt;&lt;P&gt;I had tried exactly that as well but with no luck.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 08:17:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442072#M69026</guid>
      <dc:creator>thickey</dc:creator>
      <dc:date>2021-12-03T08:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Crop a JPG Image</title>
      <link>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442097#M69029</link>
      <description>&lt;P&gt;OK, so it looks like I just didn't understand how the crop function works. Fundamentally you need to know the height and width of the image you are cropping and work with those values when you crop, relative to the LHS and TOP Edges&lt;/P&gt;&lt;P&gt;Left = Number of pixels to remove from left side&lt;/P&gt;&lt;P&gt;Right = 'Width' (in pixels) of remaining image to keep&lt;/P&gt;&lt;P&gt;Top =&amp;nbsp;Number of pixels to remove from top of image&lt;/P&gt;&lt;P&gt;Bottom =&amp;nbsp;'Height' (in pixels) of remaining image to keep&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;img = open("D:\WaferMaps\8PTPCVEB\wafer.jpg", jpg);
imgX = (img &amp;lt;&amp;lt; GetSize)[1];
imgY = (img &amp;lt;&amp;lt; GetSize)[2];
win1 = newWindow("Original", img);

myTrimBy = 5;
img &amp;lt;&amp;lt; crop(left(myTrimBy),right(imgX - myTrimBy), top(myTrimBy), bottom(imgY - myTrimBy));
win2 = newWindow("Cropped", img);

img &amp;lt;&amp;lt; savePicture("D:\WaferMaps\8PTPCVEB\waferCropped.jpg", jpg);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="thickey_2-1638520391500.png" style="width: 974px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38129i6AEE77FD65BEEFC1/image-dimensions/974x443?v=v2" width="974" height="443" role="button" title="thickey_2-1638520391500.png" alt="thickey_2-1638520391500.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 08:35:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442097#M69029</guid>
      <dc:creator>thickey</dc:creator>
      <dc:date>2021-12-03T08:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: Crop a JPG Image</title>
      <link>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442121#M69033</link>
      <description>&lt;P&gt;Nice job. The Right and Bottom definitions you provided are not exactly as you specified. Your script is spot on!&lt;/P&gt;
&lt;P&gt;See the script below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
img = Open( "$SAMPLE_IMAGES/tile.jpg", jpg );

s = {w,h} = img &amp;lt;&amp;lt; get size();
show( s ); //{451, 451}
obj = New Window( "tile(40,40)", img );
Wait( 1 );
img &amp;lt;&amp;lt; Crop( Left( 50 ), Right( 100 ), Top( 60 ), Bottom( 150 ) );
s = {w,h} = img &amp;lt;&amp;lt; get size();
show( s ); //{50, 90}

//img is a matrix of pixels the initail size is 1 to 451 columns aka "w" width
//and "h" is height 1 to 451 rows

//Crop Left(x) is the starting column and Right(y) is the ending column 
//Top() and Bottom() works the same, so after the crop the width is 100-50=50
//and the height is  150-60=90&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Dec 2021 09:20:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442121#M69033</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2021-12-03T09:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: Crop a JPG Image</title>
      <link>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442124#M69036</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11634"&gt;@Thierry_S&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I would have thought the same way, this behaviour is strange, as the documentation say: "creates new image ...".&lt;/P&gt;&lt;P&gt;But in fact crop is changing the current image, so into my eyes the documentation is not correct, it is misleading.&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1450"&gt;@tonya_mauldin&lt;/a&gt;&amp;nbsp;, do you think the documentation has to be changed according to this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
img = Open( "$SAMPLE_IMAGES/tile.jpg", jpg );
Print( "Size before crop:", img &amp;lt;&amp;lt; get size );

img &amp;lt;&amp;lt; Crop(
	Left( 50 ),
	Right( 400 ),
	Top( 50 ),
	Bottom( 400 )
);

Print( "Size before crop:", img &amp;lt;&amp;lt; get size );
print("So crop changes the image and does not create a new one as written in the documentation");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/16.1/?os=win&amp;amp;source=application&amp;amp;utm_source=helpmenu&amp;amp;utm_medium=application#page/jmp/images.shtml" target="_blank"&gt;Images (jmp.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 09:43:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442124#M69036</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2021-12-03T09:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: Crop a JPG Image</title>
      <link>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442271#M69054</link>
      <description>&lt;P&gt;Yes, it is a non-obvious interface and wants better doc. @Anonymous&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;pixels = [
-11 -11 -11 -11 -11 -11 -11 -11 -11,
-11 -11 -91 -99 -99 -99 -99 -92 -11,
-11 -11 -99 -99 -99 -99 -99 -99 -11,
-11 -11 -99 -99 -99 -99 -99 -99 -11,
-11 -11 -99 -99 -99 -99 -99 -99 -11,
-11 -11 -93 -99 -99 -99 -99 -94 -11];

img = New Image( pixels );
{hSize, ySize} = img &amp;lt;&amp;lt; size;
Show( img &amp;lt;&amp;lt; getsize, img &amp;lt;&amp;lt; getpixels );

// crop the -11 out of the image
img &amp;lt;&amp;lt; crop( Left( 2 ), Right( 8 ), top( 1 ), bottom( 6 ) );
Show( img &amp;lt;&amp;lt; getsize, img &amp;lt;&amp;lt; getpixels );

////    img &amp;lt;&amp;lt; getsize = {6, 5};
////    img &amp;lt;&amp;lt; getpixels = 
////    [	-91 -99 -99 -99 -99 -92, 
////        -99 -99 -99 -99 -99 -99, 
////        -99 -99 -99 -99 -99 -99, 
////        -99 -99 -99 -99 -99 -99, 
////        -93 -99 -99 -99 -99 -94];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="The zero-based pixel indexes are on the hairlines between the pixels." style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38143iABF9CCE6A572B0C8/image-size/large?v=v2&amp;amp;px=999" role="button" title="ImageCropZeroBased.png" alt="The zero-based pixel indexes are on the hairlines between the pixels." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;The zero-based pixel indexes are on the hairlines between the pixels.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 15:24:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442271#M69054</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2021-12-03T15:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Crop a JPG Image</title>
      <link>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442361#M69064</link>
      <description>&lt;P&gt;Thank you for bringing this to my attention. What document is being referenced in previous comments?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Qiana&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 19:28:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442361#M69064</guid>
      <dc:creator>Qiana_Eaglin</dc:creator>
      <dc:date>2021-12-03T19:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Crop a JPG Image</title>
      <link>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442473#M69072</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/9474"&gt;@Georg&lt;/a&gt;&amp;nbsp; pointed to &lt;A href="https://www.jmp.com/support/help/en/16.1/?os=win&amp;amp;source=application&amp;amp;utm_source=helpmenu&amp;amp;utm_medium=application#page/jmp/images.shtml" target="_blank" rel="noopener"&gt;https://www.jmp.com/support/help/en/16.1/?os=win&amp;amp;source=application&amp;amp;utm_source=helpmenu&amp;amp;utm_medium=application#page/jmp/images.shtml&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Which appears identical to the &lt;STRIKE&gt;scripting guide&lt;/STRIKE&gt;. syntax reference.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture1.PNG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38148i51FD4ED35FE9BA97/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture1.PNG" alt="Capture1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd point to the scripting index:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/38147iE9381E7BDC99710A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Both say "creates a new image" but only the existing image is modified, which was part of the confusion, and neither does a good job explaining the parameters. There is another crop, for a segment, that is distinct from this one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for looking at it!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 23:57:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/442473#M69072</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2021-12-03T23:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: Crop a JPG Image</title>
      <link>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/750593#M93161</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/982"&gt;@Craige_Hales&lt;/a&gt;&amp;nbsp;:)&lt;/img&gt;&lt;BR /&gt;very (!) helpful&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Apr 2025 10:38:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Crop-a-JPG-Image/m-p/750593#M93161</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-04-18T10:38:35Z</dc:date>
    </item>
  </channel>
</rss>

