I build my action for create image thumbs, and I want add to the end of action auto rotate to my thumb. My question is: How add rotate with random angle from -45 to 45 degree?
+1
A:
You can rotate an image automatically via an Adobe Script:
if (!app.documents.length > 0) {
alert("No active document");
}
else {
var docRef = app.activeDocument;
var docWidth = docRef.width.as("px");
var docHeight = docRef.height.as("px");
if (docWidth > docHeight) {
docRef.rotateCanvas(90);
}
}
Random numbers can be generated with:
this.rawValue = Math.random() * (45 - 1) + 1;
I've not done enough Adobe Script to tell you how to put this all together, but I'm sure you are clever enough!
Helpful site: http://www.photoshopsupport.com/tutorials/jennifer/photoshop-scripts.html
Enjoi!
Neurofluxation
2010-05-18 15:59:41
A:
Sorry for another answer, I didn't want to make my other one massive and unreadable.
I have attempted (VERY BADLY) the script (and, for the record, it's not been tested or anything and I'm not great at this)
if (!app.documents.length > 0) {
alert("No active document"); //no document?! whats happening?!
} else {
var docRef = app.activeDocument;
var docWidth = docRef.width.as("px");
var docHeight = docRef.height.as("px");
if (docWidth > docHeight) { //if width is greater than height
PlusMinus.rawValue = Math.random() * (2 - 1) + 1; //GET 1 OR 2
if (PlusMinus.rawValue == 1) {
deLimit = "-"; //set minus if its a 1
} else {
deLimit = "+"; //set plus if its a 2
}
Angles.rawValue = Math.random() * (45 - 1) + 1; //GET NUMBER FROM 1-45
docRef.rotateCanvas(deLimit+Angles);
}
}
I'm sure you will get the idea from that!
Neurofluxation
2010-05-18 16:07:44
I would use `Math.random() * 90 - 45` to get a random angle from -45 to 45. Your method eliminates all values between -1 and 1.
Gabe
2010-05-18 16:15:37
Cheers @Gabe, there you go @kicaj - us great people are helping you out!
Neurofluxation
2010-05-18 16:18:34