How can I create a pixmap based on a .png file? - linux

I have some .png icons I want to use for window buttons in a custom theme I want to create For fluxbox. My operating system is Arch Linux. But, fluxbox works with pixmaps.
Question: Is it possible to create pixmaps based on .png format files?

You can use the program convert from ImageMagick:
xiawi#here:~/Images$ convert lena.png lena.xpm
xiawi#here:~/Images$ file lena.xpm
lena.xpm: X pixmap image, ASCII text, with very long lines

Related

Is it possible to make Inkscape autotrace PNG to SVG, but from the command line?

I want to automate "raster to vector" conversions. PNG to SVG. (most Qs here on SO are the other way around)
I have tried the old command line tool autotrace on Linux, but I could not get it to run. I've tried to install a package, and to compile it from the source. Nope.
Then I've realised that Inkscape has "autotrace" now integrated in its codebase. I'd like to convert simple sketches from PNG to SVG.
And I want to do this in a Bash for-loop , with different autotrace settings (number of passes; ignore Speckles with max X pixels width) etc.
I've tried the "action" command-line option
inkscape --without-gui --actions="file-open:my.png"
and this brings up the small "png bitmap image import" dialog, waiting for me to confirm.
Also I've tried the verb command line option
inkscape --with-gui --verb="FileImport:my.png"
and this opens the large "Select file to import" dialog (ignoring my --verb argument)
At this point I gave up.
I want Inkscape to import a PNG picture, autotrace it with some settings, save it as SVG. Perhaps, beofre saving, duplicate the traced layer, lock the imported background layer, rename the layers from path-12345 to "tracesettings-x-y-z" etc.
(my final goal is to permute the tracing settings, to find good ones for my use-case, but that's not the focus of this question)
Inkscape is using potrace and autotrace to trace bitmap images into vector formats such as SVG and PDF.
Let's assume you have an image: foo.png that you want to trace to SVG using potrace:
First, you need to convert your image to a bitmap format (BMP).
Invoke the potrace command
# I am using ImageMagick convert command to convert PNG to BMP
convert foo.png foo.bmp
# Invoke potrace command with SVG backend
potrace -b svg foo.bmp
The result will be: foo.svg.

Creating a multi layered psd file with "editable text" using command line

I am trying to create a PSD file using command line (linux/osx).
Example:
I have 5 blocks of text
"hello"
"this"
"is"
"an"
"example"
I need a way to take these 5 blocks of text and generate a psd that will have 5 different layers for each text block and i need them to be editable after the psd has been generated and opened in photoshop.
Are you guys familiar with any software that can do this?
I tried GIMP and ImageMagick and i was able to generate a psd with 5 layers with the text blocks in there but unfortunately imageMagick seems to turn the text into an actual image so this makes the text non editable once opened up in photoshop.
You can use Applescript or Extendscript to script Photoshop itself - there is a guide available here.
You can do something like this using the Applescript version:
tell application "Finder" to set thePath to (home as string) & "TestText.tif"
set thePosix to quoted form of POSIX path of thePath
display dialog thePosix
do shell script "touch " & thePosix
tell application "Adobe Photoshop CC"
activate
make new document with properties {name:"Testtextlayers"}
make new art layer at current document with properties {kind:text layer}
make new art layer at current document with properties {kind:text layer}
tell text object of art layer 1 of current document
set {contents, size, stroke color} to {"Hello", 30.0, {class:RGB hex color, hex value:"913b8e"}}
end tell
tell text object of art layer 2 of current document
set {contents, size, stroke color, position} to {"World", 48.0, {class:RGB hex color, hex value:"339966"}, {3, 4}}
end tell
set myOptions to {class:TIFF save options, image compression:none, byte order:Mac OS, save alpha channels:true, save spot colors:true, embed color profile:true}
save current document in file thePath as TIFF with options myOptions appending no extension without copying
end tell
The Extendscript version may be more portable across Linux and Windows.
Indeed - most software able to manipulate PSD images can only work with a subset of it. GIMP itself will only open text PSD layers as pixels.
My hint for your workflow would be to script this from inside photoshop, and create another kind of file, with text-markup, that would be rendered there. Doing that would not be possible through the command line, though -
(maybe it could be automated with GUI automation tools).
Ah - it just hit me - maybe you could work with the SVG file format, and have it converted to PSD later (the conversion would still require manual interaction inside Photoshop though - but maybe the SVG file is close enough you can ship it directly to your final users, isntead of a PSD)
As for an SVG approach: create a new template file in Inskcape, and possition
your 5 blocks of text wherever you like. The final result will contain your text in XML blocks looking like this:
<text
xml:space="preserve"
style="font-size:40px;...font-family:Sans"
x="140"
y="123.79075"
id="text2999"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3001"
x="140"
y="123.79075">MyText here</tspan></text>
Replace the actual text (My text here) whtih a markup such as {}, and then you can create your svg files with a python oneliner such as:
python -c "import sys; open(sys.argv[2], 'wt').write(open(sys.argv[1]).read().format(*sys.argv[3:]) )" template.svg drawing.svg My other text file shines
The advantage of this approach is that you can actually style and format the template in very detailed ways. (hmm..browsing around, it looks like photoshop can't simply open SVG files...too bad anyway - maybe you can swithch your needed workflow away from it?)

ImageMagick convert SVG with text and external fonts to SVG with shapes (outlines) with no external fonts

I'm looking to to use ImageMagick to convert an SVG file with text and external fonts to another svg without text, instead have them be shapes or outlines.
Basically, can ImageMagick do the equivalent of Illustrator's "Create Outlines" functions?
I can currently convert the svg to png and all the text and fonts render correctly, but I'm just looking to remove need for the person opening the svg to have the correct fonts installed on their computer.
I believe that your installation of ImageMagick needs to be configured with the the "--with-autotrace" switch and Autotrace needs to be installed. Then a simple conversion command should work:
convert text.png vector.svg
I doubt ImageMagick will do it. What you need to do is load the SVG into an editor like Inkscape. Select the text and then convert it using Path->Object to Path.
Then you can save it and you can distribute it without worrying about the user not having the fonts.

How to display a .bmp in an NSImageView for MacOs so that a certain color is transparent?

I have some .bmp files that have some color (maybe black) that is supposed to show as transparent when the graphic is displayed on top a form, so the form color comes through the transparent areas. But by default, when I put these images in an Image View, the black/transparent areas show up as BLACK!
I'm thinking I need to either:
- alter how the NSImageView shows the image, so that a certain color is transparent, or
- modify the .bmp files somehow to make that color suitable for transparency in an NSImageView
But I don't know enough about graphics files, transparency(alpha), NSImageView, nor the image editing tools. I'm trying to use Gimp, but...not sure what I'm doing yet. It seems like there is already a color that should be transparent in the current .bmp file.
I'm sure its something simple for setting NSImageView, or editing my file, or perhaps making a mask for the image, but I don't know how yet. I've looked at various filters in IB for NSImageView, but have not found where to set the transparent color, nor how to grab that color from the image file to make sure I use the correct value.
Thanks in advance for any assistance. (I tried to post some images, but because I'm new, I could not.)
Beau
I'm not a Cocoa developer, but in Gimp try adding an alpha channel to your image (a layer mask, perhaps) then saving as a 32-bit PNG image (with an alpha channel), then load that PNG directly into your NSImageView. If you want to make the black pixels transparent in Gimp use the magic-wand tool to select them (use magic-wand with 0 tolerance) and just delete the contents of the selection then save as a PNG directly.

Flash CS5 - How to change anti-aliasing on all text containers in an animation

Is there a quick way to change all text containers so that the anti-alias setting is "Use Device Fonts"?
I am using Flash CS5, and need to convert about 300 animations, each with 20 or more text boxes, so that they use device fonts. This is necessary so that we can more easily display traditional Chinese characters.
I can go through each text box, change the font to _sans and it automatically switches to Use Device Font - then I don't need to embed the font files. So I tried to use the Find and Replace tool to change the font on all text boxes. It worked fine at changing the fonts, but it did not auto-switch the anti-alias. Any help on this would save hours of work.
Thanks.
Hopefully you're not too far into your work on this one, but there's a new development with CS5 that will help you with just this. It's called the .xfl format, and all .fla's are actually this format, but zipped up. Have a read here for more info: http://blog.theflashblog.com/?p=1986
What this means is you can convert your fla to xfl (or just change the suffix to .zip and unzip as the above article suggests), and do a Find&Replace on all text field font values.
Hope that helps!

Resources