Adobe 23101764 Scripting Guide - Page 73

Set jpgSaveOptions = CreateObjectPhotoshop.JPEGSaveOptions

Page 73 highlights

Scripting Photoshop 3 Document object When using the save command there are a number of specifiable options. These options are grouped by file type in the provided save options classes. Because the type and contents of the file you are working on affects how it is saved, some of the option values may not always be applicable. It also means that many of the option values do not have well defined default values. The best way to determine what values can or should be used for save is to perform a save command from the user interface and then copy the value from the options dialog to your script. You should perform a complete save operation because there can be multiple dialogs presented before the document is saved. If you cancel one of the save dialogs without completing the operation you could miss a dialog containing values needed in your script. There are many objects that allow you to specify how you want to save your document. For example, to save a file as a JPEG file, you would use the JPEG save options (JPEGSaveOptions/JPEGSaveOptions) class as shown below. AS: tell application "Adobe Photoshop CS" make new document set myOptions to {class:JPEG save options, ¬ embed color profile:false, format options: standard, ¬ matte: background color matte,} save current document in file myFile as JPEG with options ¬ myOptions appending no extension without copying end tell VB: Dim appRef As New Photoshop.Application Set jpgSaveOptions = CreateObject("Photoshop.JPEGSaveOptions") jpgSaveOptions.EmbedColorProfile = True jpgSaveOptions.FormatOptions = psStandardBaseline jpgSaveOptions.Matte = psNoMatte jpgSaveOptions.Quality = 1 appRef.ActiveDocument.SaveAs "c:\temp\myFile2", _ Options:=jpgSaveOptions, _ asCopy:=True, extensionType:=psLowercase Photoshop CS Scripting Guide 69

  • 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
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105

Photoshop CS Scripting Guide
69
Scripting Photoshop
Document object
3
When using the save
command there are a number of speci
able options. These options are
grouped by
le type in the provided save
options classes. Because the type and contents of the
le you are working on affects how it is saved, some of the option values may not always be
applicable. It also means that many of the option values do not have well de
ned default
values.
The best way to determine what values can or should be used for save
is to perform a save
command from the user interface and then copy the value from the options dialog to your
script. You should perform a complete save operation because there can be multiple dialogs
presented before the document is saved. If you cancel one of the save dialogs without
completing the operation you could miss a dialog containing values needed in your script.
There are many objects that allow you to specify how you want to save your document. For
example, to save a
le as a JPEG
le, you would use the
JPEG
save options
(
JPEGSaveOptions/JPEGSaveOptions
) class as shown below.
AS:
tell application "Adobe Photoshop CS"
make new document
set myOptions to {class:JPEG save options, ¬
embed color profile:false, format options: standard, ¬
matte: background color matte,}
save current document in file myFile as JPEG with options ¬
myOptions appending no extension without copying
end tell
VB:
Dim appRef As New Photoshop.Application
Set jpgSaveOptions = CreateObject("Photoshop.JPEGSaveOptions")
jpgSaveOptions.EmbedColorProfile = True
jpgSaveOptions.FormatOptions = psStandardBaseline
jpgSaveOptions.Matte = psNoMatte
jpgSaveOptions.Quality = 1
appRef.ActiveDocument.SaveAs "c:\temp\myFile2", _
Options:=jpgSaveOptions, _
asCopy:=True, extensionType:=psLowercase