Photoshop Custom Shape to SVG path string
Asked Answered
K

5

35

Is there any way to get the SVG path string off a Photoshop custom shape or path? Or is there another way to get/construct similar data? I'm looking to do something similar to this:

http://raphaeljs.com/icons/

Kink answered 24/3, 2011 at 1:28 Comment(0)
S
47

Update: in recent versions of Photoshop, there is a built-in option to export the image as SVG, which works well on paths and custom shapes. Just do:

File -> Export -> Export as... and select SVG in the file settings.

Original Answer:

Starting from Photoshop CC 14.2, you can create SVG files directly from Photoshop:

  1. Create a file named generator.json with the content below in your user home folder.
  2. Restart Photoshop and open your PSD file.
  3. Activate the generator: File > Generate > Image Assets.
  4. Rename your layer to <something>.svg.
  5. The svg file will be created in the assets directory next to your PSD file.

Content for generator.json:

{
    "generator-assets":  { 
        "svg-enabled": true
    }
}

Source: http://creativedroplets.com/generate-svg-with-photoshop-cc-beta/

Stahl answered 28/4, 2014 at 9:24 Comment(5)
This answer should have been selected as the correct one. No need of external tools. Works great. Thanks @Tzach!Tredecillion
Updating this as the selected answer. Thanks!Kink
Nice work. Thanks for staying up-to-date and changing the accepted answer.Wheelock
Related wiki document: github.com/adobe-photoshop/generator-core/wiki/…Skewbald
@Stahl How to generate string for vector drawable from svg imageKarolynkaron
W
43
  1. Select and copy the path in Photoshop
  2. Launch Adobe Illustrator
  3. Create a new Document
  4. Paste
  5. Save as SVG

If you have Illustrator and have not created all the paths, however, it is probably easier to create them directly in Illustrator.

If you do not have Illustrator, you are probably better off using the free Inkscape SVG editor to draw your paths.

If you do already have the paths in Photoshop, and do not have Illustrator, the best I can think of is to turn on the Info palette in Photoshop select the path points one at a time and manually record the positions of the point itself as well as its handles, and from those manually create the path using absolute curveto commands, 'C' (for the points with handles) and absolute lineto commands, 'L' for those points that have no handles.

Wheelock answered 24/3, 2011 at 13:5 Comment(3)
Thanks! I don't currently have illustrator loaded, but I might have access to it. after saving as SVG, it would give me the shorthand string command?Kink
@WillHaynes Yes, Illustrator saves out valid SVG, and for paths will create a <path> element with the d attribute using the terse curveto and lineto commands.Wheelock
I got annoyed doing this manually, so I created a PS script that will automatically export your layers to SVG for you (provided you have Ill. installed). hackingui.com/design/export-photoshop-layer-to-svgHumidity
L
5

Another option is to save the file as EPS in photoshop making sure to have export vectors checked, and then loading that into illustrator and saving as SVG

Lefthand answered 28/1, 2013 at 7:55 Comment(1)
This worked for me, thanks! Specifically, for what I was working on, I was able to take a layer with vectors, right click -> Convert to Smart Object, right click -> Edit Contents, which opened in a new photoshop document tab, and then Save As... to an EPS.Kataway
P
3

All answers were good, but for me they were too much, there is an online tool provided by Adobe:

http://adobe.com/go/extract_tryitnow_en

All you have to do is upload /drag & drop/ your .psd file, choose the path layer and download as svg. And you can extract the svg path, d attribute in particular.

Then what I did is put the path into a g element, then scaled g and translated the path

Piggery answered 1/10, 2014 at 10:14 Comment(0)
G
2

For custom shapes, you may want to have a look at the recently released open-source script called Convert Custom Shapes File to SVG Set (for Photoshop CS3 or later), used to convert a custom shapes file (.csh) or a custom shapes preferences file (CustomShapes.psp) into a set of SVG files.

Garrygarson answered 6/4, 2015 at 19:56 Comment(1)
This answer was extremely helpful to me!Doxia

© 2022 - 2024 — McMap. All rights reserved.