Skip to main content
Participant
Jun 4, 2025 2:25 AM UTC
Answered

Scripting: export only user slices in Save to Web

I'm working with a script that exports slices of a PSD.

Just wondering how to program my JS script to export only user slices (see image)?

By default it exports all, including unnecessary auto slices.

Thanks

Stephen Marsh
Stephen MarshCorrect answer
Community Expert
Jul 11, 2025 1:05 AM UTC

Comparing the ScriptListener recordings for an export with All Slices vs. User Slices, the key differences appear to be:

 

File Name (ovFN) for All Slices:

desc103.putString( idovFN, """myTestSliceDoc_01.jpg""" )

 

File Name (ovFN) for User Slices:
This line apparently isn't used/required

 

_______________

 

Slice Selection (SWsl) for All Slices:

desc103.putEnumerated( idSWsl, idSTsl, idSLAl );

 

Slice Selection (SWsl) for User Slices:

desc121.putEnumerated( idSWsl, idSTsl, idSLUs );

 

Hope this helps. 

4 replies

Stephen Marsh
Community Expert
Community Expert
Jul 11, 2025 12:34 AM UTC

Presuming legacy ExtendScript, not UXP... This isn't covered by the DOM, so you would need AM code. Have you tried ScriptListener?

Translate
Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
Jul 11, 2025 1:05 AM UTC

Comparing the ScriptListener recordings for an export with All Slices vs. User Slices, the key differences appear to be:

 

File Name (ovFN) for All Slices:

desc103.putString( idovFN, """myTestSliceDoc_01.jpg""" )

 

File Name (ovFN) for User Slices:
This line apparently isn't used/required

 

_______________

 

Slice Selection (SWsl) for All Slices:

desc103.putEnumerated( idSWsl, idSTsl, idSLAl );

 

Slice Selection (SWsl) for User Slices:

desc121.putEnumerated( idSWsl, idSTsl, idSLUs );

 

Hope this helps. 

Translate
justlearn
Community Expert
Community Expert
Jun 4, 2025 6:58 AM UTC

@stronkium how would Photoshop know which 'unnecessary slices' are? 

Translate
m
chikwa
Participant
Jul 10, 2025 10:33 PM UTC

Because the other option in that 'slices' dropdown is 'selected slices', so presumably since Photoshop knows what the total are what's selected, it can ignore the unselected.

Translate