Copy link to clipboard
Copied
HeyGuys I have this script that I'm realizing for adobe photoshop which will create an artistic picture from a photo. The starting image must have at least one of the sizes of 3000px so that the effects taken from the Filter Gallery are consistent for all the photos.
The script I have down here works but the only problem is that for images bigger than 3000px he will resize them: I need a part at some point which says "if >3000 pixels then don't do anything" because I want the software to Increase the Image Size only in the case both height and width are < to 3000 pixels
#target photoshop
doc = app.activeDocument;
// setting the ruler unit to pixels
app.preferences.rulerUnits = Units.PIXELS;
// these are our values for the end result width and height (in pixels) of our image
var fWidth = 3000;
var fHeight = 3000;
if(doc.height < 3000 || doc.width < 3000) {
if (doc.height > doc.width) {
doc.resizeImage(null,UnitValue(fHeight,"px"),null,ResampleMethod.BICUBIC);
}
else {
doc.resizeImage(UnitValue(fWidth,"px"),null,null,ResampleMethod.BICUBIC);
}
}
Not sure to understand, but your script actually don't do anything if doc.height > 3000 or doc.width > 3000.
To be accurate, you should write:
if(doc.height <= 3000 && doc.width <= 3000) {
Copy link to clipboard
Copied
Not sure to understand, but your script actually don't do anything if doc.height > 3000 or doc.width > 3000.
To be accurate, you should write:
if(doc.height <= 3000 && doc.width <= 3000) {
Copy link to clipboard
Copied
exactly! my script shouldn't do anything if height or width > 3000 but it still does it.
However with your line it doesn't do it so maybe it was just a syntax error. Thank you very much sir!
Copy link to clipboard
Copied
No, I understand what you need
this script allows you to bring up to 3000px
the lower or upper images this value.
var startRulerUnits = app.preferences.rulerUnits;
var startTypeUnits = app.preferences.typeUnits ;
var startDisplayDialogs = app.displayDialogs;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
app.displayDialogs = DialogModes.NO;
var Document =app.activeDocument;
var Dimension = 3000;
var h = Document.height;
var w = Document.width;
if (h > w) {
Document.resizeImage(null,Dimension,null,ResampleMethod.BICUBIC);
}
else {
Document.resizeImage(Dimension,null,null,ResampleMethod.BICUBIC);
}
app.preferences.rulerUnits = startRulerUnits;
app.preferences.typeUnits = startTypeUnits;
app.displayDialogs = startDisplayDialogs;
Copy link to clipboard
Copied
grazie geppetto,
thank you for your reply kind sir. Your script also works but at the end it creates a slightly different result for some reason. The Script I am making is a very long mix of filters and other operations so is very hard to explain and understand what is going on. here down below you can see a preview of the script, is pretty insane.
About the Script I will keep the previous one for the moment because it works fine, any reason why you think it should be as you wrote?
thank you again, ciao!

Get ready! An upgraded Adobe Community experience is coming in January.
Learn more