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

Resize to minimum as script in Photoshop

New Here ,
Jun 15, 2018 Jun 15, 2018

Copy link to clipboard

Copied

I have a client who wants a minimum size for all images of 4500 x 2800 pixels at 300dpi. This applies wether they are vertical or horizontal.

I've tried everything- Fit to Image, Image Processor (& Pro) Lightroom & Bridge. I think it can only be done in a script, which would be something like:

Find longest edge

If < 4500 pxl then make = 4500

Scale Proportionally

Find shortest edge

If <2800 pxl then make = 2800

Scale proportionally

I'm still trying to learn scripting, but would this work & does know the correct terminology?

Matt

TOPICS
Actions and scripting

Views

1.4K

Translate

Translate

Report

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
Adobe
People's Champ ,
Jun 15, 2018 Jun 15, 2018

Copy link to clipboard

Copied

Unclear.
What should be the final file if the original file has a size, for example, 8000x2000?

Votes

Translate

Translate

Report

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
New Here ,
Jun 15, 2018 Jun 15, 2018

Copy link to clipboard

Copied

So if it was 8000 x 2000, then I figured this would deal with it:

Find shortest edge

If <2800 pxl then make = 2800

Scale proportionally

and make the 2000 to 2600 & scale proportionally so final image would be 10400 x 2600?

Matt

Votes

Translate

Translate

Report

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
LEGEND ,
Jun 15, 2018 Jun 15, 2018

Copy link to clipboard

Copied

Why you changed 2000 to 2600 if minimum length of shorter edge had to be 2800? Is it some additional calculation you didn't mention in your original post? Otherwise 2000 * 8000 should result as 2800 * 11200, shouldn't it?

Votes

Translate

Translate

Report

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
New Here ,
Jun 15, 2018 Jun 15, 2018

Copy link to clipboard

Copied

My mistake- meant to write 2800 not 2600.

I think the script from piotrf87808300 will do it.

Matt

Votes

Translate

Translate

Report

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 ,
Jun 15, 2018 Jun 15, 2018

Copy link to clipboard

Copied

You can create an action with conditional method.

The reflection of r-bin is consistent

so with files of variable sizes you can not get the result

4500 x 2800

Votes

Translate

Translate

Report

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
New Here ,
Jun 15, 2018 Jun 15, 2018

Copy link to clipboard

Copied

Apologies, but what does "The reflection of r-bin is consistent" mean?

Matt

Votes

Translate

Translate

Report

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 ,
Jun 16, 2018 Jun 16, 2018

Copy link to clipboard

Copied

LATEST

He wants to say that r-bin has made a right observation.

Votes

Translate

Translate

Report

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
Explorer ,
Jun 15, 2018 Jun 15, 2018

Copy link to clipboard

Copied

var maxWidth = 4500

var maxHeight = 2000

var Resolution = 300

var doc = app.activeDocument

if( doc.width/doc.height >= maxWidth/maxHeight ){   

    $.writeln("a")

         var proportion = doc.height/doc.width

         var newWidth = maxWidth

        var newHeight = maxWidth * proportion  

   

    }

else{

   

        var proportion = doc.width/doc.height

        var newWidth = maxHeight * proportion

        var newHeight = maxHeight

   

    }

    $.writeln([proportion,doc.width, doc.height])

ResizeImage(newWidth, newHeight, Resolution)

function ResizeImage(x, y , res){ //[width , height, resolution]

  function cTID(s) { return app.charIDToTypeID(s); };

  function sTID(s) { return app.stringIDToTypeID(s); };

    var desc3167 = new ActionDescriptor();

    desc3167.putUnitDouble( cTID('Wdth'), cTID('#Pxl'), x );

    desc3167.putUnitDouble( cTID('Hght'), cTID('#Pxl'), y );

    desc3167.putUnitDouble( cTID('Rslt'), cTID('#Rsl'), res );

    desc3167.putEnumerated( cTID('Intr'), cTID('Intp'), sTID('bicubicAutomatic') );

    executeAction( cTID('ImgS'), desc3167, DialogModes.NO );

};

Votes

Translate

Translate

Report

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
LEGEND ,
Jun 15, 2018 Jun 15, 2018

Copy link to clipboard

Copied

Your script doesn't work a way matthew_shaw wanted. It resizes image proportionally indeed, but only once. There's also mistake - should be 2800, not 2000. He also did not want larger lengths to be resized down, but only smaller legths up...

Votes

Translate

Translate

Report

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
LEGEND ,
Jun 15, 2018 Jun 15, 2018

Copy link to clipboard

Copied

Try a code I created changing other my code from this theard: Get pixel layer properties?

(function IC(v) {

     r = !~~((wh = [(aD = activeDocument).width, aD.height])[+!!v] / wh[+!v])

     if (wh < (_ = v || 4500))

     eval("aD.resizeImage(" + (r ? 'null, ' : '') + "_)"); if (!v) IC(2800)

})()

EDIT: I forgot earlier about case when PIXELS ruleUnits are not chosen, as well as resolution:

preferences.rulerUnits = Units.PIXELS; (function IC(v) {

     r = !~~((wh = [(aD = activeDocument).width, aD.height])[+!!v] / wh[+!v]); if (wh < (_ = v || 4500)) {

          eval('aD.resizeImage(' + (r ? 'null, ' : '') + '_' + (r ? '' : ', null') + ', 300)'); if (!v) IC(2800)

     }

})()

Votes

Translate

Translate

Report

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
LEGEND ,
Jun 15, 2018 Jun 15, 2018

Copy link to clipboard

Copied

In terms of the algorithm you never need to scale twice.

How about: work out XScale: target X size / actual X size and YScale: target Y size / actual Y size.

If both are greater than or equal to 1.0, nothing need be done, the file is smaller than the limit.

Otherwise, find the lower of XScale and YScale, then scale by that one amount, proportionally.


This is very similar to what you propose, except it doesn't do the work until it's finished calculating.

Votes

Translate

Translate

Report

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