Determining type of JPEG from Photoshop (EXIF?)

I need to discern between the three ways Photoshop saves JPEG files:

–Basline (“Standard”)
–Baseline Optimized
–Progressive

I understand EXIF may do this, but I have no idea what that is, how to install it, or more importantly, how to use it to accomplish this specific task from AppleScript.

Little help? :rolleyes:

Do you mean Exiftool ?

If this is what you mean, then install it, And I will help you with the scripts.
Its very easy.

set the_command_path to "/usr/bin/exiftool"
set the_Encoding to do shell script ((quoted form of the_command_path) & "  -s -s -s  -EncodingProcess  " & quoted form of (POSIX path of (choose file)))
(* 
No -s option in the line.
-->Encoding Process                : Baseline DCT, Huffman coding

The two -s -s  options get rid of extra spaces (There should be spaces in the result shown here but they do not show on this web page?, The <- - - - - > show where they would be.
-->"EncodingProcess: <- - - - - > Baseline DCT, Huffman coding (

Three -s -s -s  gets rid of spaces and tag name.
-->"Baseline DCT, Huffman coding"

*)

Kudos! EXIF working like a charm…now to go to the web site and figure it out some more, solves problems in another script I’m writing that I was trying to stay away from EXIF Tools with, but now that I have to, may as well make good use of it. :wink:

In for a penny…

Finished, seems to be working correctly.

--
-- SplashPhoto Normalizer
-- by Kevin Quosig, May 2009
--
-- Used to drag-n-drop files to convert any Progressive JPEGs to Optimized JPEG.
-- (to minimize compression degredation, switch quality to "12" when converting)
--
-- SplashPhoto for PalmOS does not read Progessive-type JPEGs
--

--
-- DECLARE PROPERTIES
--
-- debugging on?
property g_debug : false

--basic file path and names
property g_home_folder_path : path to home folder
property g_log_file_name : "SplashPhoto Normalizer.txt"


--
-- UTILITY HANDLERS
--

-- Log Entry Generation
-- With help from StephanK of MacScripter
-- http://bbs.applescript.net/viewtopic.php?pid=76607#p76607
--
on logMe(log_string, indent_level)
	if g_debug is true then --allows turning the debugger on and off so my logMe's can be left in final version
		set log_target to (g_home_folder_path & "Library:Logs:" & g_log_file_name) as text
		try
			set log_file_ref to open for access file log_target with write permission
			repeat indent_level times
				write tab to log_file_ref starting at eof
			end repeat
			write ((log_string as text) & return) to log_file_ref starting at eof
			close access log_file_ref
			return true
		on error
			try
				close access file log_target
			end try
			return false
		end try
	end if
end logMe

-- See if the file has been saved as a Photoshop file
--
on photoshopFileCreator(some_file)
	tell application "Finder"
		if creator type of file some_file is "8BIM" then
			return true
		else
			return false
		end if
	end tell
end photoshopFileCreator

-- See if the is a JPEG
--
on jpegFileType(some_file)
	tell application "Finder"
		if file type of file some_file is "JPEG" then
			return true
		else
			return false
		end if
	end tell
end jpegFileType

-- What type of JPEG is it?
--
-- REQUIRES EXIFTOOL: http://www.sno.phy.queensu.ca/~phil/exiftool/
--
-- EXIFTools syntax courtesy of
-- mark hunte of MacScripter
-- http://macscripter.net/viewtopic.php?pid=113289#p113289
--
on illegalJPEG(some_file)
	set exif_result to ""
	set command_path to "/usr/bin/exiftool"
	set exif_result to do shell script ((quoted form of command_path) & "  -s -s -s  -EncodingProcess  " & quoted form of (POSIX path of some_file))
	
	if exif_result is "Baseline DCT, Huffman coding" then
		--these are Standard or Optimized JPEGs, which do not need changes
		return false
	else
		--SplashPhoto (PalmOS) does not support other JPEG compression formats like Progressive, so flag these
		return true
	end if
end illegalJPEG

--
-- MAIN SCRIPT
--

on open actionItems
	--start log
	my logMe("--------------------------------------------------", 0)
	my logMe("SplashPhoto Normalizer Started", 0)
	my logMe("Debugging Mode = " & g_debug, 0)
	my logMe("--------------------------------------------------", 0)
	
	repeat with current_actionItem in actionItems
		
		if photoshopFileCreator(current_actionItem) and jpegFileType(current_actionItem) and illegalJPEG(current_actionItem) is true then
			my logMe("File needs fixing: " & current_actionItem, 1)
			
			--fix file type
			set current_file to (current_actionItem as text)
			
			tell application "Adobe Photoshop CS3"
				--open file
				open file current_file
				
				--save as over old file as Optimized
				save current document as JPEG in current_file with options {format options:optimized, quality:12}
				
			end tell
		end if
		
	end repeat
	
	--end log
	my logMe("--------------------------------------------------", 0)
	my logMe("SplashPhoto Normalizer Finished", 0)
	my logMe("--------------------------------------------------", 0)
end open