[GastForen Programmierung/Entwicklung AppleScript Photoshop Kanäle Kopieren ;-)

  • Suche
  • Hilfe
  • Lesezeichen
  • Benutzerliste
Themen
Beiträge
Moderatoren
Letzter Beitrag

Photoshop Kanäle Kopieren ;-)

HFPatzi
Beiträge gesamt: 37

14. Mär 2012, 11:36
Beitrag # 1 von 3
Bewertung:
(1639 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Tag zusammen,


da wir einen weiteren Maskendienstleister dazubekommen haben und dieser anstatt mit Pfaden, mit Maskenkanälen arbeitet, sah ich mich gezwungen, das mit eurer Hilfe enstandene "Pfade-Kopieren-Script" etwas umzubauen Link hier => http://www.hilfdirselbst.ch/...;;page=unread#unread

Bei dem neuen Maskendienstleister läuft das nun Folgendermaßen: wir schicken die zu maskierenden Bilder hin und bekommen die masken in Form von Photoshopdokumenten zurück. Diese psd's enthalten keine Seperationskanäle, sondern nur die reinen Masken-Alphakanäle. Und ich darf dann die Kanäle wieder auf das originalbild übertragen.

Ich bin soweit, dass mein Kanäle-kopieren-Script genau dieses tut, wenn man einen Ordner mit den Feindaten und den Masken-PSD's auf das Droplet zieht. Nur leider heissen die PSD's nicht gleich, bzw. haben hinten noch ein "_OUT" angehängt. Jetzt bin ich schon seit geraumer Zeit dabei, genau dieses "_OUT" im Dateinamen wegzubekommen, bevor die Bildpaare an Photoshop übergeben werden. Ich komm nur nicht ganz dahinter wie. Alles was ich bis jetzt versucht habe, schlug fehl.

Ein Dateipaar im Quellordner sähe folgendermassen aus:

- XX_99_99_0123456X123.tif
- XX_99_99_0123456X123_OUT.psd

sollte aber so aussehen:

- XX_99_99_0123456X123.tif
- XX_99_99_0123456X123.psd

Das Script dazu (das wie gesagt funktioniert, wenn die Dateipaare gleich heissen) sieht folgendermaßen aus:
Code
property logPath : POSIX path of (path to desktop as text) --hier wird die Error.log geschrieben    

on open listOfFolders
set TID to AppleScript's text item delimiters

set myFolder to (item 1 of listOfFolders) as text
--display dialog myFolder
set fileNameList to list folder myFolder without invisibles

processList(myFolder, fileNameList)
set AppleScript's text item delimiters to TID
end open


on processList(myFolder, fileNameList)
set AppleScript's text item delimiters to "."
repeat with i from 1 to count of fileNameList
set myPic to item i of fileNameList
if text item -1 of myPic is "psd" then
try
set tifPath to ((myFolder & (text 1 thru -5 of myPic) & ".tif") as text)
alias tifPath
set jpgPath to (myFolder & myPic) as text
sendToPhotoshop(jpgPath, tifPath)
on error e
display alert e giving up after 2
do shell script "echo " & quoted form of (e) & " >> " & quoted form of (logPath & "Error.log")
end try
end if
end repeat

end processList


on sendToPhotoshop(jpgPath, tifPath)
tell application "Adobe Photoshop CS4"
activate

open file tifPath showing dialogs {never}
open file jpgPath showing dialogs {never}

tell application "Adobe Photoshop CS4"
set docName1 to name of document 1
set docName2 to name of document 2
if docName1 ends with ".psd" then
set sourceDoc to docName1
set targetDoc to docName2
else
set sourceDoc to docName2
set targetDoc to docName1
end if



repeat with p from 1 to count of every channel of document sourceDoc

set current document to document sourceDoc

duplicate (channel p) of document sourceDoc to document targetDoc

end repeat

set MyProfile to "Adobe RGB (1998)" as string
set current document to document targetDoc

if (color profile kind of document targetDoc = working) is not true then
convert document targetDoc to profile MyProfile intent relative colorimetric with dithering and blackpoint compensation
end if

close document targetDoc saving yes
close document sourceDoc saving no

end tell
end tell

end sendToPhotoshop


Ich habe mir gedacht, das der Codeschnippsel, der das "_OUT" im Dateinamen vom Quellbild weglöscht, irgendwo im handler "processList" untergebracht werden müsste. so ála:

Code
		if characters of myPics > "20" then 
set name of myPics to (text 1 thru 20 & ".psd")
end if


oder

Code
		tell application "Finder" 
if ((get text item -1 of myPic) is "psd") and ((get name of myPic) ends with "OUT") then
try
set (name of myPic) to ((text 1 thru 20 of myPic) & ".psd") as text
end try
end if
end tell



hat aber beides nicht funktioniert :-(

Könnt Ihr mir helfen?

Wie immer, Danke im Vorraus!

Grüße
Patzi
X

Photoshop Kanäle Kopieren ;-)

Hans Haesler
  
Beiträge gesamt: 5818

14. Mär 2012, 14:39
Beitrag # 2 von 3
Beitrag ID: #491836
Bewertung:
(1598 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo Patzi,

so sollte das Umbenennen der OUT-Dateien funktionieren:

Code
on processList(myFolder, fileNameList) 
repeat with i from 1 to count of fileNameList
set myPic to item i of fileNameList
if myPic ends with "psd" then
set baseName to text 1 thru -5 of myPic
if baseName ends with "OUT" then
set baseName to text 1 thru -5 of baseName
set newName to baseName & ".psd"
tell application "Finder"
try
set (name of file (myFolder & myPic)) to newName
end try
end tell
end if

try
set tifPath to myFolder & baseName & ".tif"
alias tifPath
set psdPath to myFolder & baseName & ".psd"
sendToPhotoshop(psdPath, tifPath)
on error e
display alert e giving up after 2
do shell script "echo " & quoted form of (e) & " >> " & quoted form of (logPath & "Error.log")
end try

end if
end repeat
end processList

Das Ausziehen der Namen geschieht nun ohne die text item delimiters.

Und die Variable jpgPath habe ich in psdPath umbenannt.

Gruss, Hans


als Antwort auf: [#491818]

Photoshop Kanäle Kopieren ;-)

HFPatzi
Beiträge gesamt: 37

14. Mär 2012, 14:47
Beitrag # 3 von 3
Beitrag ID: #491838
Bewertung:
(1592 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hi Hans,

funktioniert einwandfrei.

Vielen Dank!

Gruß
Patzi


als Antwort auf: [#491836]