🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.photoshop.scripting
Article #36

Re: How to open two images, combine them, and save?

#36
From: Mark_Larsen
Date: Mon, 30 Mar 2009 10:45
88 lines
3750 bytes
A basic AppleScript solution shared�

set Folder_A to choose folder with prompt "Where are the images to resize" without invisibles
set Folder_B to choose folder with prompt "Where are the images to duplicate?" without invisibles
--
set This_Date to do shell script "date \"+%d-%m-%y\""
--
tell application "Finder"
	set File_List_A to files in Folder_A
	set Count_A to count of files in folder Folder_A
	set File_List_B to files in Folder_B
	set Count_B to count of files in folder Folder_B
	if Count_A ≠ Count_B then �
		display dialog "You have an uneven amount of pictures!!!" & return & "Check your folders and try again�" buttons {"Cancel"} default button "Cancel"
	if not (exists folder ("Combined Images " & This_Date) of desktop) then
		set New_Folder to make new folder at desktop with properties �
			{name:"Combined Images " & This_Date}
	else
		set New_Folder to folder ("Combined Images " & This_Date) of desktop
	end if
end tell
--
tell application "Adobe Photoshop CS2"
	set User_Notifiers to notifiers enabled
	set User_Rulers to ruler units of settings
	set User_Dialogs to display dialogs
	set notifiers enabled to false
	set ruler units of settings to pixel units
	set display dialogs to never
	set foreground color to {class:RGB color, red:0.0, green:0.0, blue:0.0}
	set background color to {class:RGB color, red:255.0, green:255.0, blue:255.0}
end tell
--
repeat with i from 1 to Count_A
	tell application "Finder"
		set File_A to item i of File_List_A as alias
		-- set File_Name_A to name of File_A
		set File_B to item i of File_List_B as alias
		-- set File_Name_B to name of File_A
	end tell
	tell application "Adobe Photoshop CS2"
		activate
		open File_B
		set Doc_Ref_B to the current document
		tell Doc_Ref_B
			set Pixel_Height to height
			set Pixel_Width to width
		end tell
		open File_A
		set Doc_Ref_A to the current document
		tell Doc_Ref_A
			resize canvas height Pixel_Height
			resize canvas width Pixel_Width
		end tell
		set the current document to Doc_Ref_B
		duplicate layer 1 of Doc_Ref_B to Doc_Ref_A
		close Doc_Ref_B without saving
		tell Doc_Ref_A
			-- do your stuff here
			set Doc_Name to name of Doc_Ref_A
			set Base_Name to my getBaseName(Doc_Name)
			set New_File_Path to (New_Folder as string) & Base_Name & "_Comp.tif"
			save Doc_Ref_A in file New_File_Path as TIFF with options �
				{byte order:Mac OS, embed color profile:true, image compression:LZW, save alpha channels:false, save layers:true} appending lowercase extension
		end tell
		close current document without saving
	end tell
end repeat
--
beep 3
--
tell application "Adobe Photoshop CS2"
	set notifiers enabled to User_Notifiers
	set ruler units of settings to User_Rulers
	set display dialogs to User_Dialogs
	display dialog "All Done�" giving up after 6
end tell
--
on getBaseName(fName)
	set baseName to fName
	repeat with idx from 1 to (length of fName)
		if (item idx of fName = ".") then
			set baseName to (items 1 thru (idx - 1) of fName) as string
			exit repeat
		end if
	end repeat
	return baseName
end getBaseName
Technical Details
Message-ID: <59b7a814.4@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!newshub.sdsu.edu!webcrossing
References: <59b7a814.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f5839,52ed41d12bdce69e
X-Google-Attributes: gidf5839,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII
From: Mark_Larsen@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.photoshop.scripting
Subject: Re: How to open two images, combine them, and save?
Message-ID: <59b7a814.4@webcrossing.la2eafNXanI>
Date: Mon, 30 Mar 2009 03:45:45 -0700
References: <59b7a814.-1@webcrossing.la2eafNXanI>
Lines: 98
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit