Copy link to clipboard
Copied
I need to convert .psd files to .json and this must support smart objects, this means, data should contain warp information.
I was able to extract the relevant information but I can't do it with the smart objects.
What do I need to take into account to achieve this?
Is there any language and library that will make it easier for me to complete the job?.
Copy link to clipboard
Copied
This is nonsensical. JSON is a text format for objects. Photoshop creates and edits image formats.
Copy link to clipboard
Copied
Yes, I understand, but the idea is to extract information from the PSD. I was able to extract information from each layer, but I'm having trouble doing it with the smart objects. Maybe with this example, I can explain myself more
{
"size": {"width": 1577, "height": 2100},
"layers": [
{
"id": "7aca6d04-537d-4213-bb45-de9a36a1fb01",
"layername": "Highlights",
"opacity": 100,
"size": {"height": 451, "width": 479},
"src": "x7M/rv7pN8t3N1zSWHNjydWlEFZ1GXMPd...",
"src_type": "data",
"type": "normal",
"visibility": true,
"position": {"x": 598, "y": 1302},
"scale": {"x": 1, "y": 1},
"filters": {},
"has_mask": false,
"duplicates": []
},
{
"id": "cd86358c-5f38-4914-8b76-b60b2306f911",
"layername": "Shadows",
"opacity": 100,
"size": {"height": 451, "width": 479},
"src": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAd8AAAHDCAYAAAB...",
"src_type": "data",
"type": "normal",
"visibility": true,
"position": {"x": 598, "y": 1302},
"scale": {"x": 1, "y": 1},
"filters": {},
"has_mask": false,
"duplicates": []
},
{
"id": "f1cbffa6-57b4-4043-9dc4-e606764cb1c4",
"layername": "mm_wrp:Your Image",
"opacity": 100,
"size": {"width": 310, "height": 519},
"src": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAT...",
"src_type": "data",
"type": "smart-object",
"visibility": true,
"position": {"x": 602, "y": 1299},
"scale": {"x": 1.5483870967741935, "y": 0.8805394990366089},
"filters": {
"perspective": {"active": true, "corners": [{}, {}, {}, {}]},
"warp": {
"active": true,
"bounds": {},
"name": "Warp Tool",
"slug": "warp-tool",
"meshPoints": [],
"uOrder": 4,
"vOrder": 4,
"warpPerspective": 0
}
},
"has_mask": true,
"child_object": {"layers": [], "placeholder": "placeholder", "size": {"width": 310, "height": 519}},
"mask": "821bc723-0f1a-4a7e-a08b-9e3a7d3ac93c",
"duplicates": []
}
]
Copy link to clipboard
Copied
So you aren't converting anything to JSON, you are extracting metadata.
Adobe has XMP support, you can find many scripts (Extendscript, a variant of JavaScript) posted here that deal with metadata. Or you can use EXIFTool which is a free command line app that is FAR more capable than Adobe's implementation. EXIFTool uses PERL and should be easily compatible with Python and JavaScript if you need more processing than what is built in.
Copy link to clipboard
Copied
this is interesting comment. i do think that the request is required. especially in the era of figma-like software that has the ability to export directly to json, allowing other apps to reuse the information in a good way.
Copy link to clipboard
Copied
Export WHAT to JSON? A raster image remains an image even in text formats like SVG and PostScript.
Exporting JUST the metadata isn't possible out of the box in Adobe apps, not even just to CSV file. I had to write a script to add metadata export to Bridge. Don't hold your breath on Adobe adding this to Photoshop.
Copy link to clipboard
Copied
Did you resolve your problems? Could you share the source code or library you are using so I can dig into it?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now