🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.photoshop.scripting
Article #91

Conditional Resize Not Working

#91
From: TK
Date: Fri, 26 Mar 2010 13:06
28 lines
2101 bytes
I am trying to conditionally resize images based on their pixel range,
but when I run my script regardless of size my images are sizing down
to 900 pixels.

I think my conditional is incorrectly written, can someone help me
out?


#target photoshop
app.bringToFront();

function fitImage(newImgSize) {
var doc=activeDocument;
if (doc.width > doc.height) {doc.resizeImage(newImgSize, null, null,
ResampleMethod.BICUBICSHARPER);}
if (doc.width < doc.height) {doc.resizeImage(null, newImgSize,
null,ResampleMethod.BICUBICSHARPER);}
if (doc.width == doc.height) {doc.resizeImage(newImgSize, newImgSize,
null, ResampleMethod.BICUBICSHARPER);}
}

var doc = app.activeDocument;
var startRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;

if (parseInt(doc.height, 10) > '1200px') {fitImage (1800,300);}
else if (parseInt(doc.width, 10) > '1200px') {fitImage (1800,300);}
else {fitImage (900,300);}
Technical Details
Message-ID: <530342d4-3bf2-40e1-ba0e-a16848b20780@q23g2000yqd.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!q23g2000yqd.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f5839,82d43ab35f3a6083,start
X-Google-NewGroupId: yes
X-Google-Attributes: gid7e94bc0e5b,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!q23g2000yqd.googlegroups.com!not-for-mail
From: TK <tkphoto@comcast.net>
Newsgroups: adobe.photoshop.scripting
Subject: Conditional Resize Not Working
Date: Fri, 26 Mar 2010 06:06:27 -0700 (PDT)
Organization: http://groups.google.com
Lines: 28
Message-ID: <530342d4-3bf2-40e1-ba0e-a16848b20780@q23g2000yqd.googlegroups.com>
NNTP-Posting-Host: 65.198.237.20
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: posting.google.com 1269608787 11003 127.0.0.1 (26 Mar 2010 13:06:27 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 26 Mar 2010 13:06:27 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: q23g2000yqd.googlegroups.com; posting-host=65.198.237.20; 
 posting-account=iVyRRgoAAAB_FEwegpvprl1fpX1mk4fP
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; 
 rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2,gzip(gfe),gzip(gfe)