Article View: adobe.photoshop.scripting
Article #1809Re: Scale Image Algorithm
From: Mick_Murphy
Date: Tue, 13 Jul 2004 12:59
Date: Tue, 13 Jul 2004 12:59
22 lines
1530 bytes
1530 bytes
VB snippet below which scales an image to a dimension of 800 (pixels) if either dimension is >800 and it maintains the aspect ratio. Don't know if this is what you are looking for but it might help somebody.
formImage.Width and formImage.Height are the original dimensions.
Dim height, width, aspectRatio, reductionFactor As Double
aspectRatio = formImage.Width / formImage.Height
height = formImage.Height
width = formImage.Width
If aspectRatio >= 1 Then
If width > 800 Then
width = 800
reductionFactor = 800 / formImage.Width
height = formImage.Height * reductionFactor
End If
Else
If height > 800 Then
height = 800
reductionFactor = 800 / formImage.Height
width = formImage.Width * reductionFactor
End If
End If
Technical Details
Message-ID:
<3bb50248.0@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!webxReferences:
<3bb50248.-1@webx.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f5839,eaa6a4f49ad60bac X-Google-Attributes: gidf5839,public X-Google-Language: ENGLISH,ASCII-7-bit From: Mick_Murphy@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.photoshop.scripting Subject: Re: Scale Image Algorithm Message-ID: <3bb50248.0@webx.la2eafNXanI> Date: Tue, 13 Jul 2004 05:59:56 -0700 References: <3bb50248.-1@webx.la2eafNXanI> Lines: 25 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit