Skip to main content
November 20, 2019
Answered

Extract SVG vector from PSD file

  • November 20, 2019
  • 4 replies
  • 14719 views

Hi,
Is there a way to extract bits with svg information or svg vector from an psd file ?
I try some bits parse to get information about path, vectors but it's pretty pain to do. (Adobe Photoshop File Formats Specification November 2019)
I play with CEP panel and I wana add some buttons like `extract svg from layer`, can someone help me ?

Correct answer r-bin

Not sure what you need. Maybe this will help.

 

var layer = app.activeDocument.activeLayer;

var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("layerSVGdata"));
r.putIdentifier(stringIDToTypeID("layer"), layer.id);
var svg = executeActionGet(r).getString(stringIDToTypeID("layerSVGdata"));  

alert(svg);

 

4 replies

New Participant
January 26, 2022

Good day!

Do not leasen all this advisors. I had the same problem and find out solution. From PS 22.5, August 2021, "Save as" to SVG do not suport, but you can roll back. Open Settings / Export / Options / put fly to check-box "Use Legasy "Export As"".

Now SVG must apear.

Good Luck. 🙂

Kukurykus
Brainiac
January 26, 2022

You missed out the date of this thread, Nov 20, 2019, and the original poster marked corect solution.

r-binCorrect answer
Brainiac
November 21, 2019

Not sure what you need. Maybe this will help.

 

var layer = app.activeDocument.activeLayer;

var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("layerSVGdata"));
r.putIdentifier(stringIDToTypeID("layer"), layer.id);
var svg = executeActionGet(r).getString(stringIDToTypeID("layerSVGdata"));  

alert(svg);

 

November 22, 2019

Many thanks @r-bin it works 🙂

PECourtejoie
Community Expert
November 21, 2019

Hello, I added scripting tags to your request. Not sure how to get the attention of other scripters without a dedicated sub-forum. You might try the exchange forum as well. you could also ask on the Adobe Photoshop Family forum if you need more access to the DOM

JJMack
Community Expert
November 20, 2019

Photoshop does not support Vector File like .SVG and .AI Photoshop import the file as a single pixel raster layer. There are no vectors in Photoshop for them.

JJMack
November 20, 2019

Thank you for answer, and you say it's impossible to select a layer and convert it to an svg.
I saw some plugins for photoshop like How can I export PSD vector shape layers as SVG? and with this plugin you have the option to select a layer and convert it in svg.

What they say in docs: 'Just double click on a single vector shape layer or select multiple layers with the SHIFT key and press EXPORT, set image format as SVG and press Export again.'

I think is there a way to do this trick

JJMack
Community Expert
November 20, 2019

You may be able to select some photoshop vector layers and export them as a svg file with vectors, If you select Raster layers that would be Raster image in a svg file.  A Raster image will not be converted to vectors, A normal raster image converted to vectors would most likely exceed Photoshop 8,000 layer limit.

 

There is a third party product SVG Layers that can import SVG Files into Photoshop as vector layers. Some SVG file features are not supported.  SVG files are readable text files. The Product uses Photoshop Scripting to read the SVG text and  create Shape layers.  Performance will not be that of a compiled program. Script execution is many time slower then code compiled into machine code.   Browsers and Photoshop just render a composite raster image using the SVG file text data.

 

I havs not tried to install the SVG extension into PS 2020  I did install it in CC 2019

I just installed the SVG Layers into PS 2020. It installed and seems to work as well as it can.

JJMack