Recently I was asked whether it is possible to rotate an image in a FileMaker container field. As far as I know this only is possible by exporting the image, using another application to rotate the image, and then re-importing it back into FileMaker. This solution would exist only in a Mac OS X environment, so I turned to AppleScript, and the built-in image manipulation app called Image Events.
Although I am sure refinements can be made to the process, and it currently only works on the Mac OS, the process is fairly straightforward. The file has a container field which stores an image. Another field stores the temporary path for each record’s image. I decided to capture the direction of the rotation (clockwise or counter-clockwise) as a script parameter and set up some basic buttons to handle the process for the demo. To rotate clockwise the angle is 90 degrees, while for counter-clockwise it’s 270 degrees.
Since the AppleScript uses the database name and layout name, I captured these as variables. I also set the AppleScript itself as a variable so I could step through the script and see what it generated. I then built the path for the export, and also converted the slashes to colons for the AppleScript path. Immediately after exporting the image, I ran it through the Image Events to rotate it, and then followed this up with an insert image script step, grabbing the rotated image from its Finder location. I added a platform check so this would run only on the Mac.
There are at least two plug-ins that accomplish very similar goals. 360Works’s free ScriptMaster rotates an image based on a URL, so if this image resides in a container field you first will need to export the image, apply the rotation with the ScriptMaster function, and import the modified image. CNS Image will actually rotate an image inside a container field, and has many other useful features; prices can be found at the CNS web site. Both plug-ins are cross-platform, unlike the AppleScript solution outlined here.
Sample File: ImageRotator.fp7
Thanks for the tip. Is there a reason that web viewers aren’t on the table? I’ve seen images rotated using CSS. That wouldn’t fix the image itself, but it’s worth mentioning for display purposes.
Thanks, Donovan. The web viewer is always an option. Do you have an example of the CSS code? My experience with web viewers is you need to deal with the image path in a field, not a container. Another method is to employ Javascript.
For example if you store the code in one field (HTML_Field) and the path in another a field (Path_Field), then set the Web Viewer with a Data URL method. Then in the text of the code place a marker for the image source and switch this in the Web Viewer.
…img id=”image” src=”[SOURCE_FILE]”…
“data:text/html,” & Substitute (HTML_Field ; “[SOURCE_FILE]” ; Path_Field )
The caveat is that every time you return to the record it reverts the image view to the un-rotated version. To make the rotation stick, you need an external application that changes the image and updates the Web Viewer.
Sorry, I lost track of this thread for a bit. My colleague is displaying rotated images using the technique demonstrated here.
It’s only being used on MacOS, so I can’t vouch for its compatibility with Windows.