Created
October 14, 2011 02:17
-
-
Save itoz/1286088 to your computer and use it in GitHub Desktop.
[jsx]TRG_LENG値の正方形に収まるように画像をpsdをリサイズ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//*********************************************** | |
// | |
// TRG_LENG値の正方形に収まるようにpsdをリサイズするjsx | |
// author itoz (www.romatica.com) | |
// | |
//*********************************************** | |
var TRG_LENG = 60; | |
//-------------------------------------- | |
//document size | |
preferences.rulerUnits = Units.PIXELS; | |
var bmdW = activeDocument.width.value; | |
var bmdH = activeDocument.height.value; | |
//alert(bmdW+","+bmdH); | |
//-------------------------------------- | |
//リサイズサイズ算出 | |
var maxLeng = (bmdW > bmdH ) ? bmdW : bmdH; //ターゲットのどちらか長いほう | |
var magnif = TRG_LENG / maxLeng; // 縮小率 | |
var ww = bmdW * magnif; //実際適用する幅サイズ | |
var hh = bmdH * magnif; //実際適用する高さサイズ | |
ww = (ww < 1) ? 1 : ww; | |
hh = (hh < 1) ? 1 : hh; | |
//alert("実際適用する高さサイズ" +ww+","+hh); | |
//-------------------------------------- | |
//リサイズ | |
preferences.rulerUnits = Units.PIXELS; | |
activeDocument.resizeImage(ww,hh); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment