Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

Re: what is wrong? with ID script ,auto change image size use photoshop?

$
0
0

Hi, 喜狼_edny.

 

Try the following code:

Main();

function Main() {

    var image = app.selection[0].images[0];

    var imagePath = image.itemLink.filePath;

    var myResolution=350;

    var hScale=image.horizontalScale*(myResolution/image.actualPpi[0]);

          var vScale=image.verticalScale*(myResolution/image.actualPpi[1]);

    CreateBridgeTalkMessage();

 

    function CreateBridgeTalkMessage() {

        var bt = new BridgeTalk();

        bt.target = "photoshop";

        bt.body = myResizeImage.toString() + "\rmyResizeImage('" + imagePath + "'," + hScale + "," + vScale +","+myResolution+ ");";     

        bt.send();

    }

}

function myResizeImage(imagePath, hScale, vScale,myResolution) {

    app.bringToFront();

    app.preferences.rulerUnits = Units.MM;

    var myFile = new File(imagePath);

    var myDoc = app.open(myFile);

    myDoc.resizeImage(undefined,undefined, myResolution,ResampleMethod.NONE);

    var  w=myDoc.width.value * hScale*0.01;

    var h=myDoc.height.value * vScale*0.01;

    var k=w+12.00;

    var j=h*k/w;

    myDoc.resizeImage(k,j, myResolution,ResampleMethod.BICUBICSMOOTHER);

}


Viewing all articles
Browse latest Browse all 37788

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>