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:
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
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.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With