Jump to content

Automate adobe photoshop


joelson
 Share

Recommended Posts

alternative for droplet / actions

droplet / actions are much better

just show how to make autoit

tested Adobe photoshop CS6

;by Joelson0007
;Autoitbrasil.com

#RequireAdmin
#include<array.au3>
#include<Color.au3>

;#GLOBAL LAYERS kind VARIABLES#
;--------------------------------------
Global Const $KindNormal = 1
Global Const $KindText = 2
Global Const $KindSolidFill = 3
Global Const $KindGradientFill = 4
Global Const $KindPatternFill = 5
Global Const $KindLevels = 6
Global Const $KindCurves = 7
Global Const $KindColorBalance = 8
Global Const $KindBrightContrast = 9
Global Const $KindHueSaturation = 10
Global Const $KindSeletiveColor = 11
Global Const $KindChannelMixer = 12
Global Const $KindGradientMap = 13
Global Const $KindInversion = 14
Global Const $KindThreshold = 15
Global Const $KindPosterize = 16

;#GLOBAL LAYERS Blend Variables
;--------------------------------------
Global const $BlendCOLORBLEND =22
Global const $BlendCOLORBURN =6
Global const $BlendCOLORDODGE =10
Global const $BlendDARKEN =4
Global const $BlendDIFFERENCE =18
Global const $BlendDISSOLVE =3
Global const $BlendEXCLUSION =19
Global const $BlendHARDLIGHT =14
Global const $BlendHUE =20
Global const $BlendLIGHTEN =8
Global const $BlendLINEARBURN =7
Global const $BlendLINEARDODGE =11
Global const $BlendLINEARLIGHT =16
Global const $BlendLUMINOSITY =23
Global const $BlendMULTIPLY =5
Global const $BlendNORMAL =2
Global const $BlendOVERLAY =12
Global const $BlendPASSTHROUGH =1
Global const $BlendPINLIGHT =17
Global const $BlendSATURATION =21
Global const $BlendSCREEN =9
Global const $BlendSOFTLIGHT =13
Global const $BlendVIVIDLIGHT =15
;#GLOBAL Document Canvas Variables
;--------------------------------------
Global const $canvasHORIZONTAL =1
Global const $canvasVERTICAL =2



Global $aPostition,$ObjSolidColor, $aDimension,$points

; #Photoshop object#
;--------------------------------------
$app = ObjCreate("Photoshop.Application")
$ObjSolidColor = ObjCreate("Photoshop.SolidColor.60");photoshop CS6 Acho para CS5 É Photoshop.SolidColor.50
$ObjSaveOptions = ObjCreate("Photoshop.JPEGSaveOptions.60");photoshop CS6 Acho para CS5 É Photoshop.JPEGSaveOptions.50
IF @error THEN Exit

; #Photoshop Hide#
;--------------------------------------
;~ DllCall("user32.dll", "int", "LockSetForegroundWindow", "int", 2)
;~ $app.visible = false

; #Photoshop Preferencias# ============================================================================================================
$app.Preferences.RulerUnits = 1 ;(para trabalhar com pixels)
$app.Preferences.TypeUnits = 1 ;(para trabalhar com pixels)
$app.DisplayDialogs = 3 ;(oculta todos os dialagos)

; #Photoshop opções JPG
;--------------------------------------
With $ObjSaveOptions
.EmbedColorProfile = True
.FormatOptions = 1
.Matte = 1
.Quality = 1
EndWith

; #Photoshop set colors
;--------------------------------------
_setObjSolidColor(0xff00ff)
$app.foregroundColor = $ObjSolidColor
_setObjSolidColor(0xff0000)
$app.backgroundColor = $ObjSolidColor

;#close all docs
;--------------------------------------
; Fecha os documentos que estejam abertos no Photoshop
;~ Do While app.Documents.Count
;~ app.ActiveDocument.Close()
;~ Loop

;------------------------------
;--- Arquivo para manipular ---
;------------------------------
$app.Open(@ScriptDir&'imagem.jpg')


;------------------------------
;-- manipulando o documento ---
;------------------------------
$docRef = $app.activeDocument;Documento atual
;~ $docRef.flipCanvas($canvasHORIZONTAL);
;~ $docRef.flipCanvas($canvasVERTICAL);
;~ $docRef.resizeCanvas( 100,100 );
;~ $docRef.rotateCanvas(35)
;~ $docRef.resizeImage( 500,100 );
;~ dim $aBounds[4] = [25,25,25,25]



;------------------------------
;---------- Selecões ----------
;------------------------------
MsgBox(4096,"photoshop","Trabalhando com seleções")
_setSel(500,200,0,50);setar seleção
$selected = $docRef.selection ; ---- referecia de seleção
_setObjSolidColor(0xffff00);seleciona a cor para usar na operação
With $selected
.select($points,1)
;preenche a seleção com a cor selecionada,muda o modo blend para LINEARBURN e seta transparencia para 50%
.fill($ObjSolidColor, $BlendLINEARBURN, 50, true)
.deselect()
;.selectAll();seleciona tudo
;.clear();deletar parte selecionada
EndWith



;------------------------------
;-------- Blend mode ----------
;------------------------------
MsgBox(4096,"photoshop","Trabalhando o modo de mesclagem")
$LayerA = $docRef.ArtLayers.Add()
With $LayerA
.name = 'LayerA'
.blendMode = $BlendHUE
.Kind = $KindNormal
.opacity = 50
;.visible = False ; ocultar o layer
EndWith


;------------------------------
;----- Adicionar Texto ------
;------------------------------
MsgBox(4096,"photoshop","Adicionando o layer texto")
_setObjSolidColor(0xff00);cor para esta operação
$TextLayer = $docRef.ArtLayers.Add();adiconar layer
With $TextLayer
.Name = 'TextLayer'
.Kind = $KindText ; importante; as operações abaixo só vale para um layer tipo texto
.TextItem.Contents = 'Autoit Brasil'
.TextItem.Position = _setPosition(100,100)
.TextItem.Size = 22
.TextItem.Color=$ObjSolidColor
.opacity = 50
.TextItem.font='Ravie'
EndWith

MsgBox(4096,"photoshop","Salvando o documetno"&@CRLF&'AutoitBrasil.com')
$docRef.SaveAs(@DesktopDir&"autoitBrasil.jpg",$ObjSaveOptions,true,2) ;salvar no desktop o documento modificado



;========================== Funcoes extras
Func _setObjSolidColor($hexColor)
With $ObjSolidColor
.RGB.Red = _ColorGetRed($hexColor)
.RGB.Green = _ColorGetGreen($hexColor)
.RGB.Blue = _ColorGetBlue($hexColor)
EndWith
Return $ObjSolidColor
EndFunc

Func _setPosition($x,$y)
Dim $aPostition[2] = [$x,$y]
Return $aPostition
EndFunc

Func _getDocumentDimension()
Dim $aDimension[2] = [$docRef.width ,$docRef.height]
Return $aDimension
EndFunc

Func _setSel($width,$heigth,$marginLeft,$marginTop)
Dim $points[4]
Dim $coordinates[2] = [$width,$marginTop]
$points[0] = $coordinates
Dim $coordinates[2] = [$width,$heigth]
$points[1] = $coordinates
Dim $coordinates[2] = [$marginLeft,$heigth]
$points[2] = $coordinates
Dim $coordinates[2] = [$marginLeft,$marginTop]
$points[3] = $coordinates
$app.activeDocument.selection.select($points,1)
EndFunc

automate_photoshop.rar

Edited by joelson
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...