Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

  • Newbies

I've been lurking on this forum for weeks building scripts into this database, but I'm finally no-kidding-stuck and need some help!

 

We have a layout that shows 100px images for reference purposes, but users are dragging giant images into them.  I'm trying to create a script that will take an image in a field, resize it to 100px and replace the original.  The result would be that the field now has a 100px version of what it used to have.

 

I wrote an AppleScript to run when the field has new content in it, but I can't get it to work.

 

tell application "System Events"
	keystroke "c" using {command down}
end tell

tell application "Image Events"
	set currentImage to the clipboard
	scale currentImage to size 100
	tell application "Finder" to set newImage to (container of anImage as string) & "sm_" & (name of anImage) & ".jpg"
	save currentImage in newImage as JPEG with compression level low
			
	set clipData to read file newImage as JPEG picture
	set the clipboard to clipData	
end tell

tell application "System Events"
	keystroke "p" using {command down}
end tell

set the clipboard to ""

 

In my head, the logic looks like this:

Copy what's in the field to the clipboard.

Tell the finder to make the small version.

Copy the small version to the clipboard.

Paste the small version back into the database.

Clear the clipboard.

 

My hangup right now is Filemaker doesn't even seem to be doing the keystroke "c" to copy the image in the first place.  This all seems like such a backwards way of doing things that I'm open to suggestion in a broad sense as well.

Hi,

 

actually the idea to get the data from the clipboard is inspiring... I think if this could work (no idea) you would need to tell the AppleScript to select the field in FileMaker containing the image first.

 

Better write the image to disk, do the resizing and re-add it to your container.

 

You code looks good, in case somethings still not working, the below is working fine for me and does the same.

// FileMaker Script calcualtion!
// $fileS = the POSIX path of the image inside the FileMaker temp folder for example
"tell application "Image Events"¶
	launch¶
	set the target_width to 100¶
	-- open the image file¶
	set this_image to open "" & $fileS & ""¶
		¶
	set typ to this_image's file type¶
	¶
	copy dimensions of this_image to {current_width, current_height}¶
	if current_width is greater than current_height then¶
		scale this_image to size target_width¶
	else¶
		-- figure out new height¶
		-- y2 = (y1 * x2) / x1¶
		set the new_height to (current_height * target_width) / current_width¶
		scale this_image to size new_height¶
	end if¶
	¶
	tell application "Finder"¶
		save this_image¶
	end tell¶
end tell"

 

Best,

Alexander

  • 4 weeks later...
  • Newbies

These code looks a little difficult, why not take some online image processing sdk including recizing as a template...

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.