Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Conditional Image Size

Community Beginner ,
Sep 18, 2018 Sep 18, 2018

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);

    }

}

TOPICS
Actions and scripting
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Sep 18, 2018 Sep 18, 2018

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) {

Translate
Adobe
Contributor ,
Sep 18, 2018 Sep 18, 2018

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) {

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 18, 2018 Sep 18, 2018

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 19, 2018 Sep 19, 2018

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 19, 2018 Sep 19, 2018
LATEST

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!

18_Geometric Dispersion Photoshop Actions Effect Automatic diffusion explosion polygons geometry minimal adobe actionscript.jpg

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines