straighten crop - CS2 to CS6 (and CC?)

Upload Photoshop Scripts, download Photoshop Scripts, Discussion and Support of Photoshop Scripts

Moderators: xbytor, DavideBarranca, Paul MR

User avatar
txuku
Posts: 64
Joined: Thu Jan 01, 1970 12:00 am

straighten crop - CS2 to CS6 (and CC?)

Postby txuku » Fri Aug 24, 2018 6:58 am

Bonjour

This script straightens and crops an image using rulerTool :

Code: Select all

//REDRESSEMENT RECADRAGE sans PROPORTIONS

//Script realise sur http://www.eos-numerique.com/forums/newreply.php?do=newreply&p=653101
//par Beocien ( moi meme ) avec l aide de DomDom_one et Mac64

/*
Ce script sert a redresser l image et a la recadrer

Je l ai calibre a peu pres jusqu a un angle de 11° - sans garantie apres !

Mettre MesureRecadrage.jsx dans ....\Adobe Photoshop CS2\Paramètres prédéfinis\Scripts

MODE D EMPLOI :

Utiliser d abord l outil mesure - rulerTool -( cliquez sur l outil pipette en maintenant le click
et choisir l Outil Mesure ) pour determiner l angle de recadrage.

Puis lancer le script !

Faites OK.

Mon adresse email = hallun@free.fr - Faites moi part des bugs !!!
*/


var strtRulerUnits = preferences.rulerUnits
preferences.rulerUnits = Units.PIXELS
preferences.rulerUnits = Units.CM

//Je cree un calque pour etre sur d aplatir les cadres existants eventuels :

var docRef = app.activeDocument;
var layerRef1 = docRef.artLayers.add();


docRef.flatten(); //aplatir les calques

//DonnerAngle()
var myState = app.activeDocument.activeHistoryState;
// id201 donne l angle de l instrument mesure !

// =======================================================
var id199 = charIDToTypeID( "Rtte" );
var desc55 = new ActionDescriptor();
var id200 = charIDToTypeID( "null" );
var ref11 = new ActionReference();
var id201 = charIDToTypeID( "Dcmn" );
var id202 = charIDToTypeID( "Ordn" );
var id203 = charIDToTypeID( "Frst" );
ref11.putEnumerated( id201, id202, id203 );
desc55.putReference( id200, ref11 );
var id204 = charIDToTypeID( "Angl" );
var id205 = charIDToTypeID( "#Ang" );
desc55.putUnitDouble(id201, id204, id205 );
// desc2.putUnitDouble( idAngl, idAng, 4.390000 );
//executeAction( id199, desc55, DialogModes.NO );

var debutAngle = executeAction( id199, desc55, DialogModes.NO );



Angle = debutAngle.getDouble(charIDToTypeID("Angl"));
Angle = parseFloat(Angle);

//executeAction( id199, desc55, DialogModes.NO );
//alert(Angle)

//app.activeDocument.activeHistoryState = myState; //retour a l historique precedent
//sans appliquer la rotation

executeAction( id199, desc55, DialogModes.NO );



//commence la selection

var id248 = charIDToTypeID( "setd" );
var desc51 = new ActionDescriptor();
var id249 = charIDToTypeID( "null" );
var ref23 = new ActionReference();
var id250 = charIDToTypeID( "Chnl" );
var id251 = charIDToTypeID( "fsel" );
ref23.putProperty( id250, id251 );
desc51.putReference( id249, ref23 );
var id252 = charIDToTypeID( "T " );
var desc52 = new ActionDescriptor();
var id253 = charIDToTypeID( "Top " );
var id254 = charIDToTypeID( "#Prc" );

Negatif()

function Negatif() {

//valeur negative :

if ( Angle < 0 ) {
Angle = - Angle;
}

else {
Angle = Angle;
}
}


AngleRedresse()

function AngleRedresse() {



if ( Angle <= 1 ) {
TOP = ( Angle * 3.00);
LEFT = (Angle * 1.2);
}

else if ( Angle > 1, Angle <= 2 ) {
TOP = ( Angle * 2.55);
LEFT = (Angle * 1.1);
}

else if ( Angle > 2, Angle <= 3 ) {
TOP = (Angle * 2.45);
LEFT = (Angle * 1.08);
}

else if ( Angle > 3, Angle <= 4 ) {
TOP = (Angle * 2.36);
LEFT = (Angle * 1.05);
}

else if ( Angle > 4, Angle <= 5 ) {
TOP = ( Angle * 2.33);
LEFT = (Angle * 1.);
}

else if ( Angle > 5, Angle <= 6 ) {
TOP = (Angle * 2.26);
LEFT = (Angle * 0.96);
}

else if ( Angle > 6, Angle <= 7 ) {
TOP = ( Angle * 2.17);
LEFT = (Angle * 0.93);
}

else if ( Angle > 7, Angle <= 8 ) {
TOP = ( Angle * 2.06);
LEFT = (Angle * 0.90);
}

else if ( Angle > 8, Angle <= 9 ) {
TOP = ( Angle * 2.01);
LEFT = (Angle * 0.87);
}

else if ( Angle > 9, Angle <= 9.5 ) {
TOP = (Angle * 1.96);
LEFT = (Angle * 0.83);
}

else if ( Angle > 9.5, Angle <= 10 ) {
TOP = (Angle * 1.92);
LEFT = (Angle * 0.815);
}

else if ( Angle > 10, Angle <= 10.5 ) {
TOP = (Angle * 1.90);
LEFT = (Angle * 0.80);
}

else if ( Angle > 10.5, Angle <= 11 ) {
TOP = ( Angle * 1.88);
LEFT = (Angle * 0.785);
}

else if ( Angle > 11, Angle <= 11.5 ) {
TOP = ( Angle * 1.86);
LEFT = (Angle * 0.77);
}

else if ( Angle > 11.5, Angle <= 12 ) {
TOP = (Angle * 1.83);
LEFT = (Angle * 0.755);
}

else if ( Angle > 12, Angle <= 12.5 ) {
TOP = (Angle * 1.81);
LEFT = (Angle * 0.74);
}

else if ( Angle > 12.5, Angle <= 13 ) {
TOP = ( Angle * 1.79);
LEFT = (Angle * 0.725);
}

else if ( Angle > 13, Angle <= 13.5 ) {
TOP = ( Angle * 1.77);
LEFT = (Angle * 0.708);
}

else if ( Angle > 13.5, Angle <= 14 ) {
TOP = ( Angle * 1.74);
LEFT = (Angle * 0.695);
}

else if ( Angle > 14 ) {
alert ( " LE RESULTAT N EST PAS GARANTIT AU DESSUS D UN ANGLE DE 14 DEGRES !!!! " + "\n" + "\r" + "\r" + "\t" + " Vous devriez prendre le temps de CADRER CORRECTEMENT ??? " );
TOP = ( Angle * 1.72);
LEFT = (Angle * 0.680);
}
}

//TOP = parseInt( TOP );
//LEFT = parseInt(LEFT );

PortPays();

function PortPays() {

//*******************************************************************************************
// si l image est en PAYSAGE :

if ( app.activeDocument.width / app.activeDocument.height > 1 )
{

BOTTOM = 100 - TOP ;
RIGHT = 100 - LEFT;
TOPS = TOP;
LEFTS = LEFT;
RIGHTS = RIGHT;
BOTTOMS = BOTTOM;
}

else {
BOTTOM = 100 - TOP ;
RIGHT = 100 - LEFT;
TOPS = LEFT;
LEFTS = TOP;
RIGHTS = BOTTOM;
BOTTOMS = RIGHT;
}
}

//alert(TOPS);

Selection()

function Selection() {
// Creation de la selection ( Prc = % a la place de Pxl ) qui se fait en pourcentage
//alert(TOPS);
desc52.putUnitDouble( id253, id254, TOPS );
var id255 = charIDToTypeID( "Left" );
var id256 = charIDToTypeID( "#Prc" );
desc52.putUnitDouble( id255, id256, LEFTS );
var id257 = charIDToTypeID( "Btom" );
var id258 = charIDToTypeID( "#Prc" );
desc52.putUnitDouble( id257, id258, BOTTOMS );
var id259 = charIDToTypeID( "Rght" );
var id260 = charIDToTypeID( "#Prc" );
desc52.putUnitDouble( id259, id260, RIGHTS );
var id261 = charIDToTypeID( "Rctn" );
desc51.putObject( id252, id261, desc52 );
executeAction( id248, desc51, DialogModes.NO );

// =======================================================
//ROGNER les pixels trensparents sur la copie de la selection


var id910 = charIDToTypeID( "CpTL" );
executeAction( id910, undefined, DialogModes.NO );
// =======================================================
var id911 = charIDToTypeID( "Hd " );
var desc213 = new ActionDescriptor();
var id912 = charIDToTypeID( "null" );
var list16 = new ActionList();
var ref191 = new ActionReference();
var id913 = charIDToTypeID( "Lyr " );
var id914 = charIDToTypeID( "Bckg" );
ref191.putProperty( id913, id914 );
list16.putReference( ref191 );
desc213.putList( id912, list16 );
executeAction( id911, desc213, DialogModes.NO );

// =======================================================
var id915 = stringIDToTypeID( "trim" );
var desc214 = new ActionDescriptor();
var id916 = stringIDToTypeID( "trimBasedOn" );
var id917 = stringIDToTypeID( "trimBasedOn" );
var id918 = charIDToTypeID( "Trns" );
desc214.putEnumerated( id916, id917, id918 );
var id919 = charIDToTypeID( "Top " );
desc214.putBoolean( id919, true );
var id920 = charIDToTypeID( "Btom" );
desc214.putBoolean( id920, true );
var id921 = charIDToTypeID( "Left" );
desc214.putBoolean( id921, true );
var id922 = charIDToTypeID( "Rght" );
desc214.putBoolean( id922, true );
executeAction( id915, desc214, DialogModes.NO );

}


docRef.flatten(); //aplatir les calques

zoom0()

function zoom0()
{
var id57 = charIDToTypeID( "slct" );
var desc15 = new ActionDescriptor();
var id58 = charIDToTypeID( "null" );
var ref6 = new ActionReference();
var id59 = charIDToTypeID( "Mn " );
var id60 = charIDToTypeID( "MnIt" );
var id61 = charIDToTypeID( "FtOn" );
ref6.putEnumerated( id59, id60, id61 );
desc15.putReference( id58, ref6 );
executeAction( id57, desc15, DialogModes.NO );
}

preferences.rulerUnits = strtRulerUnits;
Lien du script


:)

Return to “Photoshop Scripts”

Who is online

Users browsing this forum: No registered users and 3 guests