Adobe 23101335 Scripting Guide - Page 53

Photo CD Open Options PhotoCDOpenOptions/PhotoCDOpenOptions, Dim appRef As Photoshop.Application

Page 53 highlights

Scripting Photoshop 3 The Application object JS: var fileRef = new File("//MyFile.psd"); var docRef = open (fileRef); Notice that in JavaScript, you must create a File object, and it gets passed into the open command. See the JavaScript file documentation for more information. Some formats require extra information when opening. When you open a Generic EPS, Generic PDF, Photo CD or Raw image you have to provide additional information to the open command. Do this by using the various open options classes: ● EPS Open Options (EPSOpenOptions/EPSOpenOptions) ● PDF Open Options (PDFOpenOptions/PDFOpenOptions) ● Photo CD Open Options (PhotoCDOpenOptions/PhotoCDOpenOptions) ● raw format Options (RawFormatOpenOptions/RawFormatOpenOptions) The following example shows how to open a generic PDF document. AS: tell application "Adobe Photoshop 7.0" set myFilePath to alias < a file path > open myFilePath as PDF with options ¬ {class:PDF open options, height:pixels 100, ¬ width:pixels 200, mode:RGB, resolution:72, ¬ use antialias:true, page:1, ¬ constrain proportions:false} end tell VB: Dim appRef As Photoshop.Application Set appRef = CreateObject("Photoshop.Application") 'Remember unit settings; and set to values expected by this script Dim originalRulerUnits As Photoshop.PsUnits originalRulerUnits = appRef.Preferences.RulerUnits appRef.Preferences.RulerUnits = psPixels 'Create a PDF option object Dim pdfOpenOptionsRef As Photoshop.PDFOpenOptions Set pdfOpenOptionsRef = CreateObject("Photoshop.PDFOpenOptions") pdfOpenOptionsRef.AntiAlias = True pdfOpenOptionsRef.Height = 100 Photoshop 7.0 Scripting Guide 53

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91

Photoshop 7.0 Scripting Guide
53
Scripting Photoshop
The Application object
3
JS:
var fileRef = new File("//MyFile.psd");
var docRef = open (fileRef);
Notice that in JavaScript, you must create a
File
object, and it gets passed into the open
command. See the JavaScript file documentation for more information.
Some formats require extra information when opening. When you open a Generic EPS,
Generic PDF, Photo CD or Raw image you have to provide additional information to the open
command.
Do this by using the various
open options
classes:
EPS Open Options (EPSOpenOptions/EPSOpenOptions)
PDF Open Options (PDFOpenOptions/PDFOpenOptions)
Photo CD Open Options (PhotoCDOpenOptions/PhotoCDOpenOptions)
raw format Options (RawFormatOpenOptions/RawFormatOpenOptions)
The following example shows how to open a generic PDF document.
AS:
tell application "Adobe Photoshop 7.0"
set myFilePath to alias < a file path >
open myFilePath as PDF with options ¬
{class:PDF open options, height:pixels 100, ¬
width:pixels 200, mode:RGB, resolution:72, ¬
use antialias:true, page:1, ¬
constrain proportions:false}
end tell
VB:
Dim appRef As Photoshop.Application
Set appRef = CreateObject("Photoshop.Application")
'Remember unit settings; and set to values expected by this script
Dim originalRulerUnits As Photoshop.PsUnits
originalRulerUnits = appRef.Preferences.RulerUnits
appRef.Preferences.RulerUnits = psPixels
'Create a PDF option object
Dim pdfOpenOptionsRef As Photoshop.PDFOpenOptions
Set pdfOpenOptionsRef = CreateObject("Photoshop.PDFOpenOptions")
pdfOpenOptionsRef.AntiAlias = True
pdfOpenOptionsRef.Height = 100