Need help to obtain an image preview/thumbnail for a database

i am currently writing ascript which uses “image info” to extract all the information from an image (iptc data, icc data and finder info) and places it in a filemaker database.

Can anybody help me to obtain an image preview/thumbnail which can be placed into the database.

I have got this to work using graphic converter but this has to open the image which will take too long. I only need a suggestion of the image for keywording purposes. the largest icon view in the finder would be perfect.

I have also tried cutting and pasting from the application “image info” as it has an image preview window, but have failed to get this to work.


set folderPath to (choose folder with prompt "Choose a folder with pictures to import�")
set fileList to list folder folderPath
set pictureCount to 0

--create a new record for each picture
repeat with pictureFileName in fileList
	tell me to set pictureFileRef to (folderPath & pictureFileName as string)
	if folder of (info for (alias pictureFileRef)) = false then
		
		--selects only jpegs as that is all I deal with
		
		if file type of (info for (alias pictureFileRef)) is "jpeg" then
			
			tell application "Image Info"
				
				open alias pictureFileRef
				set extendedinfo to Image Info for alias pictureFileRef return dimensions as inches with extended info
				set extendedinfopixel to Image Info for alias pictureFileRef return dimensions as pixels with extended info
				set extendedinfocm to Image Info for alias pictureFileRef return dimensions as centimeters with extended info
				set displayinfo to display info for alias pictureFileRef
				set finderinfo to Image Info for alias pictureFileRef with finder file info
				set iccinfo to ICC Info for alias pictureFileRef
				set imagewidthinch to image width of extendedinfo
				set imageheightinch to image height of extendedinfo
				set imagewidthcm to image width of extendedinfocm
				set imageheightcm to image height of extendedinfocm
				set imagewidthpixel to image width of extendedinfopixel
				set imageheightpixel to image height of extendedinfopixel
				set imageresolution to image resolution of extendedinfo
				set imageformat to image format of extendedinfo
				set imagesize to image file size of finderinfo
				set imagecreator to image creator of finderinfo
				set imagefilepath to image file path of finderinfo
				set imagecreated to image created of finderinfo
				set iccprofilename to ICC profile name of iccinfo
				
				-- next bit doesn't work!
				
				--copy image preview to the clipboard
				
			end tell
			
			tell application "FileMaker Pro"
				activate
				tell database "New_Image"
					set newRecord to create record
					go to newRecord
					set cell "image_ref" of newRecord to pictureFileName
					set cell "image_width_inch" of newRecord to imagewidthinch
					set cell "image_height_inch" of newRecord to imageheightinch
					set cell "image_width_cm" of newRecord to imagewidthcm
					set cell "image_height_cm" of newRecord to imageheightcm
					set cell "image_width_pixel" of newRecord to imagewidthpixel
					set cell "image_height_pixel" of newRecord to imageheightpixel
					set cell "image_resolution" of newRecord to imageresolution
					set cell "image_format" of newRecord to imageformat
					set cell "image_file_size" of newRecord to imagesize
					set cell "image_creator" of newRecord to imagecreator
					set cell "path_to_hires" of newRecord to imagefilepath
					set cell "icc_profile_name" of newRecord to iccprofilename
					set cell "creation_date" of newRecord to imagecreated
					
					-- next bit doesn't work!
					--"image_preview" is a container field
					
					--go to cell "image_preview" of newRecord
					--paste it
					
					set pictureCount to pictureCount + 1
				end tell
				
			end tell
		end if
	end if
	
end repeat

-- display number of pictures found, also displays error if there are no images found

tell me to activate
if pictureCount = 0 then
	display dialog "There are no files that I can import, try with a folder with Jpegs in " & folderPath
else
	display dialog "Number of pictures imported using file reference: " & pictureCount
end if


You do not want to “place” an image preview in the filemaker database. This will lead to a huge database very quickly and slow down access. The best technique is to store a reference to a file in the database.

In this example, the cell “picture” is a container.


tell application "FileMaker Pro"
	tell database "Pictures"
		activate
		set cell "Picture" of current record to file (NewImageFile)
		set cell "File Name" of current record to NewImageName
	end tell
end tell

You can do this manually by ctrl-clicking on a container, select Insert Image. Then after selecting the image check the “Store only a reference to a file” box. The two downsides are that the file must be kept in the same relative location. If the file is large, Filemaker takes some time to resize it. I deal with these problems by making a small thumbnail and placing it in a picture folder for the database. I reference this file.

To make the thumbnail resize the original with “Image Capture Scripting”


			tell application "Image Capture Scripting"
				set this_image to open this_imagefile
				scale this_image to size 400
				save this_image in file NewImageFile
				close this_image
			end tell

I hope this helps.

Scott

Cheers scott.

The image thumbnail will only need to be in database for a short while. I use the thumbnail of the image to enter keywords/copyright info into the database and then it is deleted.

I can then run another script which will open the hires and place the keyword/copyright info directly into the IPTC info of the image using photoshop.

I will be importing 10-500 images at a time - so a fast way of generating this reference thumbnail is essential.

Does image Capture scripting open the Hires file before it can scale the size? because some of the images we deal with are 200mb+.

thanks
Tony

Image Capture Scripting is a scripting addition that comes with OS X, so you can give it a try. It is a faceless “app”, so you will not see it open the file. I believe it can also get many of the image information you are getting from Image Info. I have not used it on such large image files, mine are 2-3 Mb. What seems to take the longest time is Filemaker making the connection and showing the image.

A note about speeding up scripts that interact with Filemaker. I have heard many people say that bouncing back and forth between Filemaker and Applescript is slow. If you can set everything up in Applescript and then transfer it to Filemaker, that will be faster than bouncing back and forth between Filemaker and Applescript for each image. If you are looking for speed increases, you may look into this, or try the scripting language that comes with Filemaker.

I do know that if you use the big image as the reference file in the database, Filemaker will scale that and show a thumbnail. (I think you need to set the container to reduce image to fit.) But it can be slow. You may try it just to see what the speed hit is because it would eliminate the need to make thumbnails. Your computer may be much faster than mine.

Scott