Skip to main content
AG_Ps_100
Inspiring
September 15, 2018
Answered

Make Rectangle from Trapezoid

  • September 15, 2018
  • 4 replies
  • 17148 views

Hello everyone,

I have a trapezoid and i want to turn it to rectangle by using script.

it is basically something like this:

BEFORE

AFTER

i need to find the width of the small side of the trapezoid, in our case it's 2043px:

and after the transform the other side will be 2043 as well:

any ideas?

This topic has been closed for replies.
Correct answer r-bin

created a WorkPath, i'm getting this:

I wonder if it's possible to make it work without having to create a work path because the script straightens any quadrangle to rectangle did not require a work path, and the script Auto Symmetry Skew did not require a work path. a combination of the two can be pretty awesome


strai3.jsxbin - Google Drive

4 replies

Participant
May 11, 2021

Hello I have same problem. I have a trapezoid picture and i want convert it to rectangel, would you please share the solution with me?

 

 

AG_Ps_100
AG_Ps_100Author
Inspiring
January 30, 2019

r-bin​ I've noticed we solved these two issues in this thread:

1. Straightening Trapezoid

example:

BEFORE

AFTER

2. Straightens any quadrangle to rectangle

example:

BEFORE

AFTER

How can I solve my initial problem which is turning trapezoid to rectangle but keeping on original X1 and X2

(X1 and X2 being the coordinates of the top side of the trapezoid)

BEFORE

AFTER

any help?

Legend
February 1, 2019

All this is unnecessary nonsense.

strai4.jsxbin - Google Drive

AG_Ps_100
AG_Ps_100Author
Inspiring
February 1, 2019

it worked always helpful.

why "All this is unnecessary nonsense." though?

AG_Ps_100
AG_Ps_100Author
Inspiring
September 23, 2018

any chance to bother you to combine the two?

this is the auto symmetry one:

  1. app.activeDocument.suspendHistory("Skew","skew_straighten_layer()");   
  2.    
  3. function skew_straighten_layer()   
  4.     {   
  5.     try {    
  6.         app.preferences.rulerUnits = Units.PIXELS;   
  7.  
  8.         var doc = app.activeDocument;   
  9.         var layer = app.activeDocument.activeLayer;   
  10.  
  11.         selection_from_layer();   
  12.  
  13.         var dh = Number(layer.bounds[3].value - layer.bounds[1].value)*0.01; 
  14.    
  15.         select_single_line(Number(layer.bounds[1].value) + dh, true, stringIDToTypeID("intersectWith"));   
  16.  
  17.         var x0 = Number(doc.selection.bounds[2].value + doc.selection.bounds[0].value)/2; 
  18.         var y0 = Number(doc.selection.bounds[3].value); 
  19.  
  20.         selection_from_layer();   
  21.  
  22.         select_single_line(Number(layer.bounds[3].value) - dh, true, stringIDToTypeID("intersectWith"));   
  23.  
  24.         var x1 = Number(doc.selection.bounds[2].value + doc.selection.bounds[0].value)/2; 
  25.         var y1 = Number(doc.selection.bounds[3].value); 
  26.  
  27.         doc.selection.deselect();     
  28.  
  29.         var w = x1 - x0;   
  30.         var h = y1 - y0;   
  31.    
  32.         var angle;   
  33.         if (h != 0)  
  34.             { 
  35.             angle = Math.atan(w/h) * 180.0 / Math.PI;   
  36.  
  37.             skew(layer, -angle,0, x1, y1); 
  38.             } 
  39.         }   
  40.     catch (e) { alert(e) }   
  41.     }   
  42.    
  43. function select_single_line(x, h, mode)   
  44.     {   
  45.     try   
  46.         {   
  47.         if (mode == undefined) mode = stringIDToTypeID("set");   
  48.    
  49.         var r = new ActionReference();   
  50.         r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));   
  51.    
  52.         var d = new ActionDescriptor();   
  53.         d.putReference(stringIDToTypeID("target"), r);   
  54.    
  55.         var d1 = new ActionDescriptor();   
  56.         d1.putUnitDouble(stringIDToTypeID(h?"top":"left"), stringIDToTypeID("pixelsUnit"), x);   
  57.    
  58.         d.putObject(stringIDToTypeID("to"), stringIDToTypeID(h?"singleRow":"singleColumn"), d1);   
  59.    
  60.         executeAction(mode, d, DialogModes.NO);   
  61.         }   
  62.     catch (e) { throw(e); }   
  63.     }   
  64.    
  65. function selection_from_layer()   
  66.     {   
  67.     try   
  68.         {   
  69.         var r = new ActionReference();   
  70.         r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));   
  71.    
  72.         var d = new ActionDescriptor();   
  73.         d.putReference(stringIDToTypeID("target"), r);   
  74.    
  75.         var r = new ActionReference();   
  76.         r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("transparencyEnum"));   
  77.         d.putReference(stringIDToTypeID("to"), r);   
  78.    
  79.         executeAction(stringIDToTypeID("set"), d, DialogModes.NO);   
  80.         }   
  81.     catch (e) { throw(e); }   
  82.     }   
  83.  
  84. function skew(layer, h,v, x, y) 
  85.     { 
  86.     try 
  87.         { 
  88.         app.activeDocument.activeLayer = layer; 
  89.  
  90.         var d1 = new ActionDescriptor(); 
  91.         var d2 = new ActionDescriptor(); 
  92.         var d3 = new ActionDescriptor(); 
  93.         var d4 = new ActionDescriptor(); 
  94.         var r1 = new ActionReference(); 
  95.  
  96.         r1.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) ); 
  97.  
  98.         d1.putReference( charIDToTypeID( "null" ), r1 ); 
  99.  
  100.         d1.putEnumerated( charIDToTypeID( "FTcs" ), charIDToTypeID( "QCSt" ), charIDToTypeID( "Qcsi" ) ); 
  101.  
  102.         if (x != undefined &&  y != undefined) 
  103.             {    
  104.             d2.putUnitDouble( charIDToTypeID( "Hrzn" ), charIDToTypeID( "#Pxl" ), x ); 
  105.             d2.putUnitDouble( charIDToTypeID( "Vrtc" ), charIDToTypeID( "#Pxl" ), y ); 
  106.             d1.putObject( charIDToTypeID( "Pstn" ), charIDToTypeID( "Pnt " ), d2 ); 
  107.             } 
  108.  
  109.         d4.putUnitDouble( charIDToTypeID( "Hrzn" ), charIDToTypeID( "#Ang" ), h ); 
  110.         d4.putUnitDouble( charIDToTypeID( "Vrtc" ), charIDToTypeID( "#Ang" ), v ); 
  111.  
  112.         d1.putObject( charIDToTypeID( "Skew" ), charIDToTypeID( "Pnt " ), d4 ); 
  113.  
  114.         executeAction( charIDToTypeID( "Trnf" ), d1, DialogModes.NO ); 
  115.         } 
  116.     catch (e) { throw(e); }   
  117.     } 

and combine it with the jsxbin of this thread.

thanks anyway!

Legend
September 23, 2018

Mark as accurately as possible corners with four WorkPath points in the sequence as described in post # 6.

Run the script strai2.jsxbin - Google Drive

AG_Ps_100
AG_Ps_100Author
Inspiring
September 26, 2018

created a WorkPath, i'm getting this:

I wonder if it's possible to make it work without having to create a work path because the script straightens any quadrangle to rectangle did not require a work path, and the script Auto Symmetry Skew did not require a work path. a combination of the two can be pretty awesome

Legend
September 15, 2018

Try it.

Straightens any quadrangle to rectangle.

eval("@JSXBIN@ES@2.0@MyBbyBnAHMgfbyBn0ABghBbyBn0ALOhCJhDnAEjzNjFjYjFjDjVjUjFiBjDjUjJjP"+

"jOBfRDEjzQjTjUjSjJjOjHiJiEiUjPiUjZjQjFiJiECfRBFeOjOjFjXiQjMjBjDjFjEiMjBjZjFjSff"+

"jzJjVjOjEjFjGjJjOjFjEDfXzCiOiPEfjzLiEjJjBjMjPjHiNjPjEjFjTFfffACzChBhdGXzEjLjJjO"+

"jEHfXzLjBjDjUjJjWjFiMjBjZjFjSIfXzOjBjDjUjJjWjFiEjPjDjVjNjFjOjUJfjzDjBjQjQKfXzLi"+

"TiNiBiSiUiPiCiKiFiDiULfjzJiMjBjZjFjSiLjJjOjEMfnnnJhFnASzFjMjBjZjFjSNAXIfXJfjKfn"+

"ftJhHnAEjzHjSjFjGjSjFjTjIOfnfJhInAEjzMjTjJjEjFifjEjJjTjUjPjSjUPfRCVNfAFdAffJhJn"+

"AEjOfnfJhKnAEjPfRCVNfAFdCffJhLnAEjOfnfJhMnAEjPfRCVNfAFdBffJhNnAEjOfnfJhOnAEjPfR"+

"CVNfAFdDffJhQnAEXzIjEjFjTjFjMjFjDjUQfXzJjTjFjMjFjDjUjJjPjORfXJfjKfnfABnzBjFSnby"+

"Bn0ACJhSnAEXQfXRfXJfjKfnfJyhSnABjzCjPjLTfncffABN40BiAABAzEjNjBjJjOUAhTMhWbyBn0A"+

"BghYbyBn0AMJhZnASzBjQVAEjzFiBjSjSjBjZWfntnftchdnAVzEjTjJjEjFXfHFRBFdAfRBFdBfRBF"+

"dCfRBFdDfRBnfFbiAn0AEJiAnABXzBhQYfVVfAEjzJjHjFjUifjQjPjJjOjUZfRCVNfGFdAffnfJiBn"+

"ABXzBhRgafVVfAEjZfRCVNfGFdDffnfJiCnASzDjWjFjSgbBncfffDiDnAzAgctbiGn0AEJiGnABXYf"+

"VVfAEjZfRCVNfGFdBffnfJiHnABXgafVVfAEjZfRCVNfGFdAffnfJiInASgbBnctffDiJnAgctbiMn0"+

"AEJiMnABXYfVVfAEjZfRCVNfGFdCffnfJiNnABXgafVVfAEjZfRCVNfGFdBffnfJiOnASgbBncfffDi"+

"PnAgctbiSn0AEJiSnABXYfVVfAEjZfRCVNfGFdDffnfJiTnABXgafVVfAEjZfRCVNfGFdCffnfJiUnA"+

"SgbBnctffDiVnAgctbyiYn0ABZiYnAnJibnASzDjBjOjHgdCndAftJicnASzDjJjOjWgeDncfftJien"+

"ASzBjXgfECzBhNhAXYfXYfVVfAXYfXgafVVfAnnnftJifnASzBjIhBFChAXgafXYfVVfAXgafXgafVV"+

"fAnnnftOjBbyjDn0ABOjDJjDnASgdCCzBhPhCCzBhKhDEXzEjBjUjBjOhEfjzEiNjBjUjIhFfRBChCV"+

"gffEVhBfFnnffnndlUXzCiQiJhGfjhFfnnnffACGVhBfFnndAnAhzBhBhHVgbfBbyjHn0ABOjHJjHnA"+

"SgdCChCChDhzBhNhIEXhEfjhFfRBChCVhBfFVgffEnnffnndlUXhGfjhFfnnnffACGVgffEnndAnOjK"+

"bjMn0ACJjMnAEXQfXRfXJfjKfnfZjNnAFctAhhHVgdfCnOjQbyjSn0ABOjSbjUn0ADJjUnASgeDnctf"+

"fJjWnABjzBjYhJfXYfXgafVVfAnfJjXnABjzBjZhKfXgafXgafVVfAnfACzBhchLXYfXgafVVfAXYfX"+

"YfVVfAnnbjbn0ACJjbnABjhJfXYfXYfVVfAnfJjcnABjhKfXgafXYfVVfAnfAhhHVgbfBbykBn0ABOk"+

"BbkDn0ACJkDnABjhJfXYfXgafVVfAnfJkEnABjhKfXgafXgafVVfAnfAChLXgafXgafVVfAXgafXYfV"+

"VfAnnbkIn0ADJkInASgeDnctffJkKnABjhJfXYfXYfVVfAnfJkLnABjhKfXgafXYfVVfAnfJkPnAEXQ"+

"fXRfXJfjKfnfJkRnAEjzHjEjJjTjUjPjSjUhMfRGVNfGVgdfCVgbfBVgefDjhJfjhKfffZkTnAFctAB"+

"nSnbyBn0ABfkVnAjSfAIhB4F0AiAgf4E0AiAV40BiAN40BhAX4B0AhAgb4B0AiAgd4C0AiAge4D0AiA"+

"CGAPAkWMkZbyBn0ABgkbbyBn0ALJkcnABXzKjSjVjMjFjSiVjOjJjUjThNfXzLjQjSjFjGjFjSjFjOj"+

"DjFjThOfjKfXzGiQiJiYiFiMiThPfjzFiVjOjJjUjThQfnfJkenASzBjChRAXzGjCjPjVjOjEjThSfV"+

"NfKnftJlKnASgfDEjzGiOjVjNjCjFjShTfRBChAXzFjWjBjMjVjFhUfXzBhShVfVhRfAXhUfXYfVhRf"+

"AnnffnftJlLnAShBEEjhTfRBChAXhUfXzBhThWfVhRfAXhUfXgafVhRfAnnffnftOlNblPn0AFJlPnA"+

"ShJBEjhTfRBXhUfXYfVhRfAffnffJlQnAShKCEjhTfRBXhUfXgafVhRfAffnffJlSnASzEjTjUjFjQh"+

"XFVgffDnffJlUnASzGjTjJjHjOifjYhYGndBffJlVnASzGjTjJjHjOifjZhZHndBffACzChdhdhaVzF"+

"jQjPjJjOjUhbfLnndAnOlYblan0AFJlanAShJBEjhTfRBXhUfXhVfVhRfAffnffJlbnAShKCEjhTfRB"+

"XhUfXgafVhRfAffnffJldnAShXFVgffDnffJlfnAShYGndyBffJmAnAShZHndBffAChaVhbfLnndBnO"+

"mDbmFn0AFJmFnAShJBEjhTfRBXhUfXhVfVhRfAffnffJmGnAShKCEjhTfRBXhUfXhWfVhRfAffnffJm"+

"InAShXFVgffDnffJmKnAShYGndyBffJmLnAShZHndyBffAChaVhbfLnndCnOmObmQn0AHJmQnAShJBE"+

"jhTfRBXhUfXYfVhRfAffnffJmRnAShKCEjhTfRBXhUfXhWfVhRfAffnffJmTnASgfDEjhTfRBChAX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hJfQnnnnnnnffJ2iMBnASiXJChAViUfGViWfInnnffO2iSBby2iUBn0AB"+

"O2iUBb2iWBn0ACO2iWBJ2iWBnASzCjShQiZKAREViVfHViUfGViRfDViWfIfnffAhhHVgefPJ2iXBnA"+

"SiZKAREViSfFViUfGViRfDViWfIfnffO2iZBJ2iZBnASzCjOhQiaLAREARCXYfViZfKXgafViZfKfAR"+

"CXhVfViZfKXgafViZfKfARCXhVfViZfKXhWfViZfKfARCChdXYfViZfKViXfJnnXhWfViZfKffnffAh"+

"hHVgefPJ2iaBnASiaLAREARCChAXYfViZfKViXfJnnXgafViZfKfARCXhVfViZfKXgafViZfKfARCXh"+

"VfViZfKXhWfViZfKfARCXYfViZfKXhWfViZfKffnffAChLEXzDjBjCjTibfjhFfRBChAViSfFViGfBn"+

"nffEXibfjhFfRBChAViSfFViRfDnnffnnb2ieBn0ACO2ieBJ2ieBnASiZKAREViGfBViUfGViVfHViW"+

"fIfnffAhhHVgefPJ2ifBnASiZKAREViGfBViUfGViSfFViWfIfnffO2jBBJ2jBBnASiaLAREARCXYfV"+

"iZfKXgafViZfKfARCXhVfViZfKXgafViZfKfARCChdXhVfViZfKViXfJnnXhWfViZfKfARCXYfViZfK"+

"XhWfViZfKffnffAhhHVgefPJ2jCBnASiaLAREARCXYfViZfKXgafViZfKfARCChAXhVfViZfKViXfJn"+

"nXgafViZfKfARCXhVfViZfKXhWfViZfKfARCXYfViZfKXhWfViZfKffnffAhhHViYfOby2jHBn0ABO2"+

"jHBb2jJBn0ACO2jJBJ2jJBnASiZKAREViSfFViQfCViVfHViWfIfnffAhhHVgefPJ2jKBnASiZKAREV"+

"iSfFViQfCViVfHViUfGfnffO2jMBJ2jMBnASiaLAREARCXYfViZfKXgafViZfKfARCXhVfViZfKXgaf"+

"ViZfKfARCXhVfViZfKChdXhWfViZfKViXfJnnfARCXYfViZfKXhWfViZfKffnffAhhHVgefPJ2jNBnA"+

"SiaLAREARCXYfViZfKXgafViZfKfARCXhVfViZfKXgafViZfKfARCXhVfViZfKXhWfViZfKfARCXYfV"+

"iZfKChAXhWfViZfKViXfJnnffnffAChLEXibfjhFfRBChAViUfGVhRfEnnffEXibfjhFfRBChAViUfG"+

"ViQfCnnffnnb2jRBn0ACO2jRBJ2jRBnASiZKAREViSfFViWfIViVfHVhRfEfnffAhhHVgefPJ2jSBnA"+

"SiZKAREViSfFViUfGViVfHVhRfEfnffO2jUBJ2jUBnASiaLAREARCXYfViZfKXgafViZfKfARCXhVfV"+

"iZfKChdXgafViZfKViXfJnnfARCXhVfViZfKXhWfViZfKfARCXYfViZfKXhWfViZfKffnffAhhHVgef"+

"PJ2jVBnASiaLAREARCXYfViZfKChAXgafViZfKViXfJnnfARCXhVfViZfKXgafViZfKfARCXhVfViZf"+

"KXhWfViZfKfARCXYfViZfKXhWfViZfKffnffJ2jaBnAEjiNfRCViZfKViafLffJ2jcBnABXhNfXhOfj"+

"KfViPfAnfABnSnbyBn0ABf2jeBnAjSfAShJ4E0AhAhK4F0AhAiY4C0AhAiR4D0AiAiS4F0AiAiQ4C0A"+

"iAiU4G0AiAiV4H0AiAiW4I0AiAiZ4K0AiAia4L0AiAiX4J0AiAiG4B0AiAiP40BiAN40BhAiO4B0AhA"+

"ge4D0AhAhR4E0AiAGMAhMA2jfBM2kCBbyBn0ABg2kEBbyBn0AIJ2kGBnASiRAEjzPiBjDjUjJjPjOiS"+

"jFjGjFjSjFjOjDjFicfntnftJ2kHBnAEXzLjQjVjUiQjSjPjQjFjSjUjZidfViRfARCEjCfRBFeHjDj"+

"IjBjOjOjFjMffEjCfRBFeJjTjFjMjFjDjUjJjPjOffffJ2kJBnASiEBEjiFfntnftJ2kKBnAEXzMjQj"+

"VjUiSjFjGjFjSjFjOjDjFiefViEfBRCEjCfRBFeGjUjBjSjHjFjUffViRfAffJ2kMBnASiRAEjicfnt"+

"nftJ2kNBnAEXiMfViRfARDEjCfRBFeHjDjIjBjOjOjFjMffEjCfRBFeHjDjIjBjOjOjFjMffEjCfRBF"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j"+

"DjUjFjYjUjDfFeEiXjBjJjUffnfJLnABXzFjXjJjEjUjIjOfXzNjQjSjFjGjFjSjSjFjEiTjJjajFjP"+

"fXjMfVjBfyBndlAfJMnABXzHjKjVjTjUjJjGjZjQfXjMfVjBfyBneGjDjFjOjUjFjSfJOnAEXzEjTjI"+

"jPjXjRfVjBfyBnfJQnASTyBnctftOSJSnAEXzOjTjVjTjQjFjOjEiIjJjTjUjPjSjZjSfXJfjKfRCFe"+

"KiTjUjSjBjJjHjIjUjFjOFeGjNjBjJjOhIhJffAXzGjMjFjOjHjUjIjTfXzJjEjPjDjVjNjFjOjUjTj"+

"UfjKfnOUbWn0ACJWnAEjBfRDEjCfRBFeJjVjOjEjPiFjWjFjOjUffjDfXEfjFfffJXnAEXjSfXJfjKf"+

"RCFeEiVjOjEjPFeAffAhhHVTfyBnJganAEXzFjDjMjPjTjFjVfVjBfyBnfJgcnABXhNfXhOfjKfViPf"+

"yBnfADT4C0AiAiP40BiAjB4B0AiAADAgcByB");

AG_Ps_100
AG_Ps_100Author
Inspiring
September 19, 2018

I used r-bin​'s Straightens any quadrangle to rectangle script and i straightened a rectangle to the canvas (works perfect):

BEFORE

AFTER

I want to straighten a trapezoid in a way that it will fit up side of the layer to up side of the canvas, and down side of the layer to down side of the canvas automatically, just like that:

BEFORE

AFTER

this is where i got so far (after using r-bin's script):

if I use Free Transform > Perspective I can manually change it to:

BUT there is a difference in the location of X1 and Y1, X2 and Y2.

i made some calculations and i think my logic is right and it's just a matter of execution by script.

So let's say this is how my original trapezoid looked like:

X1 = 650

X2 = 2650

X2-X1 = 2000

Canvas Width = 4000

and here is how it should be:

X1 = 1000

X2 = 3000

X2-X1 = 2000

Canvas Width = 4000

This is how to get there:

Y1 should be = (4000-2650+650) /2 = 1000

in other words (Canvas Width - X2 + X1) * 0.5

Y2 should be = 4000-1000 = 3000

in other words Canvas Width -Y1

After I know where my Y1 and Y2 needs to be, there must be an automatic way to:

1. Distort top left corner to Y1

2. Distort top right corner to Y2.

Any kind of help will be appreciated

Legend
September 22, 2018

r-bin​ any ideas?


I already gave you similar scripts for alignment. Search.
You can use the script from my post # 6. After the quadrilateral becomes a rectangle, add an empty layer from above, link it with a smart object or select both at the same time and call perspective transform. After that, the empty layer can be deleted.