Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webserver replies to ?q="/path/to/file" with a "path bar" png

I want to write a CGI script that accepts a posix path as a string, and returns a png representing it. Eg:


If the script is sent the string /System/Library/CoreServices/Finder.app,

it will return the following png file: /System/Library/CoreServices/Finder.app


An example based in any scripting platform that comes bundled with the Mac is fine by me (Python, Perl, AppleScript, BASH). I might not know it, but I can muddle through to get an idea of what I need to do.

I think what I'm looking for is a way to generate an NSPathCell-style widget, and dump its contents into an image file

like image 571
username Avatar asked May 14 '11 18:05

username


2 Answers

Depending on the context, it might be reasonable to use -dataWithPDFInsideRect: instead of generating a PNG.

Of course, if you’re getting an image (especially a pixmap image) of a UI element like this for web use, there’s a 95 % chance that you deserve a punch in the face from the Accessibility Gorilla.

like image 165
Jens Ayton Avatar answered Oct 04 '22 18:10

Jens Ayton


That's an NSPathControl. To take an NSString and split it up into the path components, you can invoke the -[NSString pathComponents] method. If you want that actual png, you'd have to either do the rendering yourself or take an NSPathControl, force it to draw into a context that you control, and then turn that context into an image yourself.

Bigger question: what are you trying to accomplish?

like image 21
Dave DeLong Avatar answered Oct 04 '22 20:10

Dave DeLong