Rotate a Image in FileMaker

Hello,

Looking at this forum I have seem many topics similar to this. So I attempted to peice together a script to perform the rotation, however it does not work.

What I have is a FileMaker photo database, what I am trying to do is rotate the image for optimal printing.

On the layout where the image is viewed I have installed a button to rotate the image. It is o.k. to have the images sideways, when we use the db we are looking at the thumbs, which are not rotated.

What I have below removes the image from the db, but I do not get a return.



---Caution, this script does not work, it removes your Image
tell application "FileMaker Pro"
	activate
	tell window "Photo Database copy 1"--This is the name of my db
		tell layout "Photo Database"  -- this is the name of the layout the image is viewed in, and where the rotate button is located.
			set theFile to "Image" -- This is the name of my container field
		end tell
	end tell
	
	
	try
		tell application "Image Events"
			launch
			set this_image to open theFile
			rotate this_image to angle 90
			save this_image in theFile
			close this_image
		end tell
	end try
	
	
	tell application "FileMaker Pro"
		tell window "Photo Database copy 1"
			tell layout "Photo Database"
				try
					set cell "Image" of current record to theFile
				end try
			end tell
		end tell
	end tell
end tell

I am a novice at both FileMaker Pro Scripting and AppleScript so please provide details with any answer so I will understand and learn.

Thank You, very much!

higashijoe,

your script is just about done you did almost everything right …

as along as you are only storing a reference to the file it will work here is what you need to change your script to


tell application "FileMaker Pro Advanced"
	activate
	tell window "Photo Database copy 1" --This is the name of my db
		tell layout "Photo Database" -- this is the name of the layout the image is viewed in, and where the rotate button is located.
			set theFile to "Image" -- This is the name of my container field
			
			tell application "Image Events"
				launch
				set this_image to open theFile
				rotate this_image to angle 90
				save this_image in theFile
				close this_image
			end tell
			
			do script "refresh" -- make a script in filemaker called "refresh" with script step  "refresh" ist in the window commands
			
		end tell
	end tell
end tell

Thank You Mcgrailm,

However, I am storing the image’s in the db. I have seen threads advising against this practice, but I have decided (at this point) to import them anyway. I have over 100 users who will be able to access this db and add/remove photo’s. Most are not computer savey, and the problems having a separate storeage would cause I am not sure would be worth it (adding/removing image’s to/from the right location, relinking the images if need be).

I do have a dedicated G5 2ghz server w/ 3x400gig HD’s, 2 set up to raid, 1 as bu, for this purpose (all our FM db’s) anything I could put the photo’s on would be much slower. the best I have is a G4 QS 733mhz. Maybe I should put in for something.

I don’t know, what does everyone think?

Thanks,

higashijoe,

I strongly recommend that you only store a referecne to the file. You will bog down your system trying to store all the photos in the database you could add buttons to your layout to add, remove the image from the database. these buttons would need to call the an apple script that would then upload in the case of adding an image or delete the contents of the container cell and the image on the disk.

MM

higashijoe,

Since you are using applescript within your DB, why not manage the import process for your users to make a foolproof method to store the photos outside of the DB (as MM stated above)?

I’ve worked on a few that are using a “hybrid” approach“ importing thumbnails to embed in the DB (for viewing speed) with stored references for hi rez detail views of the images.

-N

Hi Nedloh99,
Thanks for the input!
Actually, I have taken Mcgrailm’s advice and have almost completed the import (as folder script)

I just need to figure out how to reference the image name for a name feild and also get the thumb.
I am already importing the reference to the image.

Being a novice at all scripting I have learned allot over the past week. I have my script selecting a folder the user choose’s (handy when importing direct from a camera) making a folder at the storage location, named the date and time (so no matter what they will not over write anything)transfering the files. Then bringing the link back to FileMaker in a new record.
I have tried to make it very user freindly so I have Bruce Phillips Progress Bar script running and showing a count while transfering, and then again when making the new records.

All and all its been a frustrating (at times) and rewarding experience.

higashijoe

higashijoe

if you post the code and highlight the areas you are having trouble with maybe we could help ?

mm

OK, This is kind of long and I am sure there are ways to clean it up.

This is working fine as of about 2 hours ago, I now need to get the Image name and thumb to put in their respective fields in the db.


try
	mount volume "afp://storagecomp.local/User" as user name "User" with password "User PW" 
end try

set theDate to current date
set shortDate to short date string of theDate
set theMonth to word 1 of shortDate
set theDay to word 2 of shortDate
set theYear to word 3 of shortDate
set DateString to theMonth & "/" & theDay & "/" & theYear

set theTime to time string of theDate
set theHour to word 1 of theTime as number
set DayNight to last word of theTime
if DayNight is "PM" then set theHour to theHour + 12
set theHour to theHour as text
if the length of theHour is 1 then set theHour to "0" & theHour
set theMinutes to word 2 of theTime
if the length of theMinutes is 1 then set theMinutes to "0" & theMinutes
set theSeconds to word 3 of theTime
if the length of theSeconds is 1 then set theSeconds to "0" & theSeconds
set TimeString to theHour & "-" & theMinutes & "-" & theSeconds
set FinalString to DateString & " " & TimeString

set myAlias to ("User:Desktop:folder")

set targFolder to choose folder -- choose folder

tell application "Finder"
	set myList to every file of folder targFolder -- make list of items
end tell

set itemCount to count of myList -- Count items
set myCount to itemCount

display dialog "You have selected  " & itemCount & " Images to Import"

set progress to load script alias ((("Macintosh HD:Library:Scripts:Progress Script:") as text) & "Progress.scpt") -- compliments of Bruce Phillips and MacScripters

tell progress -- starts progress bar
	initialize()
	setTitle to "Transfering Images" -- puts window title in progress bar
	
	barberPole(false) -- spinning barber pole off
	setStatusTop to "Moving images to storage location" -- text above progress bar
	setMax to itemCount -- set progress to my number of files being moved
	tell application "Finder"
		set theFolder to make new folder at myAlias with properties {name:FinalString}
	end tell
	
	repeat with i from 1 to number of items in myList
		set thisPic to item i of myList
		setStatusBottom to "Images left to move " & myCount --Sets count below progress bar
		
		try
			tell application "Finder"
				set newPic to move (thisPic) to theFolder
			end tell
			
		end try
		
		set myCount to (myCount - 1) -- count down for below progress bar
		increase by 1 -- this increases the progress bar
		
	end repeat
	
end tell

set testFolder to get theFolder as alias -- works

tell application "Finder"
	set newList to every file of folder testFolder -- make list of items
end tell
set newCount to count of newList -- Count items
set thisCount to newCount

tell progress
	setTitle to "Connecting Images to Database"
	barberPole(false)
	setStatusTop to "Making New Records in FileMaker"
	setMax to newCount
	
	repeat with i from 1 to number of items in newList
		set pictureFile to item i of newList
		setStatusBottom to "Records Left to Make " & thisCount
		
		set folderPath to theFolder
		
		set pictureFileRef to pictureFile
		
		tell application "FileMaker Pro"
			do script ("Go To Photo Database")
			set newRecord to create record
			set cell "Image" of newRecord to file ((pictureFileRef) as string)
		end tell
		set thisCount to (thisCount - 1)
		increase by 1
	end repeat
	quit
	
end tell


Thank You fro any ideas,

higashijoe