Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5592 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Not all files have 3 character extensions. You may want to account for that.

Let([

Name = table::FileName;

dots = PatternCount(Name; ".");

lastdot = Postion(Name; "."; dots);

end = Length(name)-lastdot;

ext = Case(end > 0; Middle(Name; lastdot; end))];

ext

)

Posted

Oh I have just managed to alter the applescript to automatically handle pdf files....

It looks like this...

The script now imports pdf files but does not resize them nut does resize pictures... Great....

set tempFolder to path to temporary items

set tempFolder_txt to tempFolder as Unicode text

property theSize  762

global smFile

global myDisk





tell application "Finder"

	set myDisk to name of startup disk

	set theFile to choose file

	set itsKind to kind of theFile

	if not (itsKind contains "Image" or itsKind contains "JPEG" or itsKind contains "PNG" or itsKind contains "TIFF" or itsKind contains "PICT" or itsKind contains "GIF" or itsKind contains "PDF") then

		-- or itsKind contains "PDF"; not doing PDF in this script

		-- .jpg, .png, .gif, .bmp, .pcd usually have "Image", .pdf, .pct and .tif do not; files without "Image" have "Document", i.e., "PDF Document"

		beep

		return

	end if

	

	set newFile to duplicate theFile to tempFolder with replacing

	

	set name_orig to name of theFile

	set theExt to ("." & name extension of theFile)

	if (theExt is not ".jpg" and theExt is not ".png" and theExt is not ".pdf") then

		set name_only to my nameOnly(name_orig, theExt)

		set new_name to (name_only & ".jpg")

		set theThumb to (tempFolder_txt & new_name)

		if not (exists file theThumb) then

			set name of newFile to new_name

		end if

	else

		set theThumb to (tempFolder_txt & name_orig)

	end if

	

	set smFile to theThumb as file specification

	if not(itsKind contains "PDF") then

	tell application "Image Events"

		launch

		set this_image to open smFile

		scale this_image to size theSize

		if theExt is ".png" then

			set newFile to save this_image as PNG

		else

			set newFile to save this_image as JPEG

		end if

		close this_image

	end tell

	end if

	my FM_Insert(smFile)

	

end tell





on nameOnly(fileName, ext)

	set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ext}

	set theName to first text item of fileName as string

	set AppleScript's text item delimiters to TID

	return theName

end nameOnly



on FM_Insert(smFile)

	set UnixPath to myDisk & (POSIX path of smFile as Unicode text)

	set cell "Filepath" of current record to UnixPath

		

	

end FM_Insert

Posted

Is there any scripting Language in Windows like applescript ?

There is VB script. Not like Applescript in syntax but will do the same things. However, I think a better option is to install Python on Windows and use the Python Imaging Library (PIL) library found here:

http://www.pythonware.com/products/pil/

The tutorial is very good and will do want you want.

Python is standard on OS X so you should be able to have a script which runs cross platform.

Posted

Not like Applescript in syntax but will do the same things

Isn't this somewhat of an overstatement? How many of filemaker's own objects (shown above) are within reach with Python???

--sd

Apple_Events_Reference.jpg

Posted (edited)

So you are saying Python is not really up to the job of Applescript ?

I mean I'm not surprised Applescript is a very mature and wonderfully easy language to use, I mean I use small applescripts via terminal using Cron to control Applications using osascript which is really so easy....

Edited by Guest
Posted

And then there's the command-line driven ImageMagick distribution, several platforms, incl. Mac and Windows. It's pretty geeky, even to install (which I haven't). But I believe it can do most anything to do with images.

http://www.imagemagick.org/script/index.php

Posted

Fenton it seems like the yellowduck thingy uses web-companion to get data into filemaker and xml objects as responses ... is it something you dared poke into?

--sd

Posted

AFAIK, AppleScript is unique among all the external scripting languages in the sense that it allows direct control of the Filemaker application itself. All the other methods (VBS, Python, Javascript, PHP, Java, etc.) require a plugin in order to return a result into the FM file - or at least that the file be served and set to respond to external queries. Otherwise all they can do is to put the result in a text file, which can then be imported from within Filemaker itself.

Posted

I would be interested in looking at say using Imagemagic to achieve the same results as the applescript I posted.....

Just to achieve cross platform compatibility with what I am doing, my questions are

1/ could IT ?

2/ If it could which plugin would you use

3/ What would the script then look like...

Posted

require a plugin in order to return a result into the FM file

Webcompanion isn't a dedicated plugin any more ... at least isn't it listed among the plugins any more.

--sd

Posted

ImageMagick is run by command line. On a Mac this could be in different ways. I tend to still use the Perform AppleScript step to run command line, because I'm often mixing "plain vanilla" AppleScript with short 1-line command line.

An example of using a mix of AppleScript, also running Unix command line to do much what we did with Image Events, using, sips - scriptable image processing system.

set x to quoted form of POSIX path of (choose file)

set f to do shell script "basename " & x

set y to do shell script "cp " & x & " ~/Desktop"

do shell script "sips -Z 128 ~/Desktop/" & quoted form of f

Alternately, I it could all be done (likely faster) by just using straight command-line, using a plug-in like the free zipShell, at http://www.zipptools.com/

On Windows there are similar plug-ins, such as Shell, by Abstrakt (also no longer online), and the newer Spider plug-in (which was distributed in an fmwebschool newsletter, but which also I don't know how to access online).

I don't know if other "image" plug-ins would let you specify the "quality" of a JPEG. That is the sticking point here. Many tools to resize, few which have the quality option. I saw that ImageMagick did.

I suppose you could also run a plug-in that let your run PHP. It likely has image processing classes available somewhere. I don't really know.

Posted

Wikipedia has further links:

Asido

[color:red]Asido is an open-source PHP (PHP4/PHP5) image processing solution, with "pluggable" drivers(adapters) for virtually any environment (either GD2 (php_gd2), ImageMagick via shell, ImageMagick via extension (php_imagick), MagickWand (php_magickwand), etc).

[color:red]ImageMagick ImageMagick

[color:red]Netpbm Netpbm

  • 1 year later...
  • Newbies
Posted (edited)

Ok, I haven't installed and fiddled with this yet, mainly because this applescript stuff seems a little out of my league to fiddle with. however, this seems to be the right thread. Is it possible to resize and save images that are already placed? I just started a project for a client that has a 6000 record database. they have been placing in images as PCT and super-sized jpg's (20+MB) for quite some time. Thus the database is now hugely bloated (4GB). Is there a way to modify this script to batch process thru an existing database by exporting the image, resizing, saving as a JPG, and reimporting (keeping the existing filename)? I dream of getting this database down to a manageable size.

update: i've been fiddling with this for a while. i think the best i can determine is found here: Link last post where it is stated that "the Finder's duplicate command doesn't behave the same way under 10.5 than under 10.4."

Thoughts?

Edited by Guest
  • Newbies
Posted

Ok, so the update is that I downgraded my laptop to 10.3 and filemaker 7 to try to get this to work. Still no luck with either the database or the script. the script gets much further than before... It now stops at "do script FILEMAKER script "Insert Picture""

  • 2 weeks later...
  • Newbies
Posted

Wow has it been over a week that i've been fiddling with this? Really. Ugh. Oh well, at least I came up with a sloppy, but successful three step solution.

I used the apple automator to create a script that would select and copy the field I want to rename the file to, then export the image, paste the collected name into the save dialog, and select the next record.

To make the automator file loop, just google 'loop automator' and you'll find an app that makes the script loop.

Once the images were out and had the correct names, I batch processed them with photoshop and created a similar automator script to reimport them into filemaker.

This time, the script copy's the name field and pastes it into the "find" area of the open dialog to select the file.

a little slow, but effective and still better than doing it by hand.

This topic is 5592 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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