How do I create s:Path.data, polygon coords? - apache-flex

I have a PNG image, the image features a shape surrounded by a transparent area:
I want to recreate this image as a path in flex mxml, something like this:
<s:Path data="M 0 0 L 0 100 L 100 100 L 100 0 L 0 0" />
How can I export the path data so that I can use this shape in Flex, is there a program that will do this for me?

Illustrator will export an FXG, as will Photoshop.

My problem was that my original image was a flat file, not a path. This meant that following #www.Flextras.com's answer didn't work for me, the result was an FXG with an image embedded.
The process I used is as follows, I used Adobe Fireworks for this:
1) Magic wand selection
Select the body of the image with magic wand.
2) Convert to path
Right click -> Modify Marquee -> Convert to Path
3) Export as FXG
File -> Export
4) Done
Open the FXG in notepad and extract the path data.

Related

I am trying to save 360 png files as a gif with image magick in R (I am working with MacOS)

please let me know any other system/code I need to include, as I am not as familiar with writing out images to my computer. I am creating 360 png files as follows:
for(theta in 1:360){
ic=as.character(theta)
if(theta<10) ic=paste("00",ic,sep="")
if(theta>=10 & theta<100) ic=paste("0",ic,sep="") # make filenames the same length
fn=paste("c:iris360\\HW4_",ic,".png",sep="") #filename
png(fn,width=1000,height=1000) # save as *.png
p3(X1,X2, r=100,theta=theta,mainL=paste("theta =",theta))
# legend("topleft",pch=16,cex=1.5,col=allcl)
dev.off()
}
system("magick c:iris360\\HW4*.png c:iris.gif")
where p3 is just a function that takes my matrices X1 and X2 and plots the points and their segments(let me know if I need to include it as well). However, I get this error:
magick: must specify image size iris360HW4*.png' # error/raw.c/ReadRAWImage/140.
I am unable to open the gif file, as my mac says it is damaged or uses a file format that preview does not recognize.
Update 1: I replaced fn's declaration with
fn <- sprintf("c:iris360/HW4_%03i.png", theta)
as well as replacing ic with sprintf("%03i", theta) everywhere it appeared, but still got the same specify image size error.
When I run the system command into my terminal, I still get the same error asking me to specify the image size.
Magick needs to know several things (e.g., image size, delay between frames, images to use, destination file name) in order to convert a stack of png into a gif. See GIF Animations and Animation Meta-data
magick -delay 100 -size 100x100 xc:SkyBlue \
-page +5+10 balloon.gif -page +35+30 medical.gif \
-page +62+50 present.gif -page +10+55 shading.gif \
-loop 0 animation.gif
So it looks like you need to change
system("magick c:iris360\\HW4*.png c:iris.gif")
to something more like
system("magick -delay 10 -size 100x100 —loop 0 c:iris360\\HW4*.png c:iris.gif")

Command-line equivalent of CSS filter

I'm currently working with pictures and I try to do the same thing as the CSS filter below but in command line:
filter: invert(0.86) hue-rotate(180deg);
To do the trick I used imagemagick's convert tool.
convert $in -evaluate add -26% -negate -modulate 100,100,0 $out
I get close to the result I expect, but I have a huge quality drop. Let's show this in an example
Original version (a random jpg image)
Clean version (made with CSS, expected result)
Dirty one, made with convert
Is there any way (with this tool or another) to convert my image smoothly? The best would be to directly apply css to this image but I don't know whether it's possible in commandline...

How does indesign calculate itemtransform

For a project im working on i need to know how indesign calculates/generate itemtransform
when the element is not rotated the itemtransform = "1 0 0 1 0 0"
then when I rotate the element 90deg then the itemtransform = "1 -0.5 0.5 1 somecordinate someothercordinate"
open indesign >
new Document >
place an rectangle for example >
save as "enter_name_here".idml >
change the name to "enter_name_here".zip >
extract the files to folder >
open Spreads/spread_ud7.xml in notepad++ and find the itemtransform
now go back to indesign, rotate the rectangle and do the above again, then look at the itemtransform how is that calculated in indesign?
why is that and how is it done if have look in almost every documentation but could not find a clear awnser
anyone have an idea?
Find some info inside this PDF:
https://www.adobe.com/content/dam/Adobe/en/devnet/indesign/cs55-docs/IDML/idml-specification.pdf
i.e. on page 97

How can I verify a SVG doc is correct? (version 1.2)

I used a program called Fritzing to draw some basic Arduino schematics, and then export the output as a SVG. This works just as expected, but then I noticed that the SVG output only looks okay in some browsers and only okay in some versions of Firefox.
Since Fritzing is a open source app I figured that I could look into the code (and maybe help out a little).
But now over to the question, what is a correct SVG supposed to look like? What verifier over at W3C can I use to check the file?
I tried to use the verifiers found on this page: http://validator.w3.org/dev/tests/
But they all complained a lot, especially about the SVG version. The verifiers seem to like version 1.0 and 1.1, but when I look at the top of this file seems to be using version 1.2?
This is the top three lines from the problematic file (reformatted for readability):
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<!-- Created with Fritzing (http://www.fritzing.org/) -->
<svg width="3.50927in"
x="0in"
version="1.2"
y="0in"
xmlns="http://www.w3.org/2000/svg"
height="2.81713in"
viewBox="0 0 252.667 202.833"
baseProfile="tiny"
xmlns:svg="http://www.w3.org/2000/svg">
Is there a specific SVG 1.2 verifier I can use?
Or shall I try to verify the SVG as if it was a classical XML file?
(As a side note, Fritzing seems to use Qt, so if there some QTest I can use it may be useful.)
You can use e.g http://validator.nu. Since your file is standalone, select xml parsing, paste the RNG url in the schema textfield (the schema url you're looking can be found in the relevant specification, in this case SVG 1.2 Tiny: http://www.w3.org/TR/SVGTiny12/relaxng/Tiny-1.2.rng ).
Even your three line snippet isn't valid SVG 1.2 Tiny content (x and y attributes are not allowed on the <svg> element in Tiny). You should add a link to your file somewhere, otherwise it's hard to say what it should look like.
There is a python utility in terminal svgcheck, which claims to target version 1.2, as defined in draft-7996-bis. A promising utility, IMHO.
SVG Checking Procedure.
pip install svgcheck
svgcheck ~/path/to/mysvgfile.svg
The svg file with proper standards will give something like:
$ svgcheck alert-circle.svg
Parsing file alert-circle.svg
INFO: File conforms to SVG requirements.
Make sure you have pip installed and python configured properly
For the subset SVG Tiny 1.2 Portable/Secure (SVG P/S), used for example in Brand Indicators for Message Identification (BIMI), see Using the RNC Schema to Validate BIMI SVG Images. It shows how to perform Relax NG Compact (RNC) XML schema validation on the command line.
pip3 install jingtrang
wget 'https://bimigroup.org/resources/SVG_PS-latest.rnc.txt'
pyjing -c SVG_PS-latest.rnc.txt my-image.svg
For my use-case, a PNG logotype converted to SVG Tiny 1.2 using png2svg, this was the output.
my-image.svg:1:159: error: value of attribute "baseProfile" is invalid; must be equal to "tiny-ps"
my-image.svg:1:174: error: element "g" not allowed yet; missing required element "title"
Errors were easily fixed by editing the baseProfile value and adding <title>A very nice image title</title>.

How to get coordinates of an svg?

How can I find out the coordinates of an svg? I have an Adobe Illustrator file that contains a map, this has been drawn and separated into US states, how can I find the coordinates of each state?
I'm just using the US map as an example, I'm going to potentially use this technique for several other maps (much more local!!).
Inkscape does that beautifully. It has a command interface, described in http://tavmjong.free.fr/INKSCAPE/MANUAL/html/CommandLine.html . (The link is to a copy of the manual on the website of its author, Tavmjong Bah. Note that it warns that the manual hasn't been updated for the latest version of Inkscape. However, the command worked fine when I tried it.)
This command
inkscape -S some_file.svg
will output lines containing an element id, the x and y coordinates of the top-left corner, and the element's width and height. There is one line for each element of the SVG. Here's an example:
svg2293,26.447175,24,97.105652,92.450851
layer1,26.447175,24,97.105652,92.450851
MyStar,26.447175,24,97.105652,92.450851
This example comes from http://tavmjong.free.fr/INKSCAPE/MANUAL/html/CommandLine-Query.html . It extracts information from an SVG which includes a star shape, shown on my first link.
On my Windows 10 system, Inkscape lives in c:\Program Files\Inkscape\ , and the executables are in the bin\ subdirectory of that. If I cd to that subdirectory, Windows will recognise the inkscape command; likewise if I use the full path to the executable from somewhere else, e.g.
"c:\Program Files\Inkscape"\bin\inkscape -S some_file.svg
Putting it on my PATH would presumably also work.
Inkscape has a lot of other commands, which include others for extracting information about object positions and sizes. The latter are called "query commands". One can extract information about a specified object, e.g.
inkscape --query-id=zoom-in -X /usr/share/inkscape/icons/icons.svg
This is an example of finding the x position of the zoom-in icon in the default icon file on a Linux system.
To save the output to a file, use > . E.g.
"c:\Program Files\Inkscape"\bin\inkscape -S some_file.svg > coords.txt
As it's reassuring to see actual examples, here are two screenshots of this working.
Once you have the data in a file, you can read it into programs. Below is a screenshot of me doing this in the R programming language, using the read_csv function ( https://readr.tidyverse.org/reference/read_delim.html ). This puts the data into a table, which I then displayed.
SVG have an XML structure. The states will be in <path> tags, hopefully with the name of the state somewhere as an attribute. The coordinates of a path are defined by the d attribute, but they can get quite complex as they can be relative or absolute and have various types of curves. With curves, it's probably simplest to consider just the final two values, which is where the curve ends.
For full details, see: http://www.w3.org/TR/SVG/paths.html#PathDataGeneralInformation
The situation may be more complex if further transforms are applied to the paths. Good luck!

Resources