How Would I open Files in GraphicConverter using Applescript?

So i want to make an applescript to do something with Graphic converter and first I need to open the file


The only example i found on how to do it is

"

set theImage to choose file with prompt "Please select an image file:"

tell application "GraphicConverter"

open theImage

end tell"


But i don't want to have a prompt, i want to just make it select a file from my computer


In tell Finder you can open a file with

"open document file "a.png" of folder "untiled folder" of folder "Desktop" of folder "username" of folder "Users" of startup disk "


but this doesn't work to open the file in Graphic converter.

How do you do it???

Mac OS X (10.6.7)

Posted on May 16, 2011 6:49 AM

Reply
6 replies

May 16, 2011 8:01 AM in response to jonsondonson

use an alias file reference:


alias "<name of startup disk>:Users:<username>:Desktop:untitled folder:a.png"


where you fill in the stuff in brackets. there are several different ways of specifying files in applescript. all of them do the same thing - give a list of the names of every containing folder all the way back to the root folder - they just do it in different formats. there's the on you gave (file "..." of folder "..." of folder "..." of startup disk) which is recognized by the Finder and System Events.app, there's POSIX paths which use text strings delimited by slashes (/Users/<username>/Desktop/untitled folder/a.png) which is used by unix and recognized by some application, and then there's colon delimited paths, which are text strings delimited by colons ("<name of startup disk>:Users:<username>:Desktop:untitled folder:a.png") and prefixed with keywords that specify the type of object (alias and file work everywhere, but some apps have special keywords for dealing with specific kinds of system objects)

May 16, 2011 8:25 AM in response to jonsondonson

First off, you can use the Finder model if you prefer - just append the using parameter to tell the Finder which app to open the file with.


The alternative is to tell the app to open the file, in which case you use an alias specifier, like:


tell application "GraphicConverter"

open alias "Mac:Users:username:Desktop:some.jpg"

end tell


Where you can see you specify the path using a colon-delimited form.

May 16, 2011 6:03 PM in response to jonsondonson

Thanks alot guys. I got it!!!!


Well that's my initial step for what i want to do.


What i want to do with graphic converter is i want to make an Applescript droplet into which the user drags a bunch of PNG files with a white NONTRANSPARENT Bground , and want my droplet

to make all thoes file's background color be transparent ...then save all those files with transparency.


So right now i don't have a clue how to do it but my algorith would be something like:


UPON RECEIVING A BUNCH OF DROPPED files


for all those files

-open the file

-Set the color WHITE to be transparent

-save the file

-close the file

end for loop



So i have other questions

1. My initial step: How would i let the script detect that a bunch of files are dropped into it?

2. My second step: How would i put all the received files into an array so i can manipulate them

3. What is the Graphic Converter command i would use to set the transparent Color of the image file that is currently being processed by the FOR loop?

I looked in the dictionary of Graphic Converter X and there is a command TRANSPARENT COLOR( RGB)


I searched for an example of using that, and i found one in the web

They use this:


tell application "GraphicConverter"

open theImage //This theImage was created somewhere in the file

tell window 1

//a bunch of other stuff which i will not write here

set transparency to true

set transparent color to {65535, 65535, 65535}

end tell

end tell


****

So i can kinda see how to set transparency but i thought RGB would be numbers from 0 to 255

so for example white would be 255 255 255.. But here it's 65535?


And would that be all it takes to turn the image's bground color( white) into transparent?


Thanks

May 16, 2011 6:34 PM in response to jonsondonson

Ok guys here's my first exercise for what i want to do.

But the transparency thing doesn't work. The open file does work!!! Thanks alot!


tell application "GraphicConverter"

activate

open alias "Macintosh HD:Users:myuser:Desktop:untitled folder:a.png"

tell window 1

set transparency to true

set transparent color to {65535, 65535, 65535}

end tell

end tell


**

While it doesn't give an error.. the BGround color doesn't get changed to CHECKER pattern. In GC, transparency is usually seen as Checkerboard pattern.


And usually to get that in the BGcolor of an image you have to use the transparency tool and click on the background (which is a solid color)

May 16, 2011 6:41 PM in response to jonsondonson

Guys i'm back and the transparency thing via applescript may not work cause the Graphic converter i'm using is Graphic converter X and i read in a site that has GC applescript examples and which was written in 2005, that


"GraphicConverter 5.6.3 (or higher, most likely) is the version of GraphicConverter that supports setting up transparency in an image via AppleScript. I wrote Lemkesoft’s support asking if it was possible to set transparency via AppleScript; they replied with a new beta version of GraphicConverter with this feature added."


So that was long time ago. The makers of GC probably didn't or haven't made transparency control via Applescript in this new version(version X). Maybe i should try my script using Graphic converter 5.6.3.

May 16, 2011 7:21 PM in response to jonsondonson

Just in case any of you are following . I just want to say i finally got it to work using Graphic Converter . ANd yup, you can't set transparency in GConverter X. I download version 5.9.5 and it works


tell application id "com.lemkesoft.graphicconverter"

activate

open alias "Macintosh HD:Users:myusername:Desktop:untitled folder:a.png"

tell window 1

set alpha channel to false

minimize color table

set transparency to true

set transparent color to {65535, 65535, 65535}

end tell

end tell

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How Would I open Files in GraphicConverter using Applescript?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.