Remove Images on master layer only?

I know it’s a dummy question… but I’m wondering how to modify the existing (Rainer’s) script that removes images on all layers for selected glyphs, so it only affects master layer, not all layers.
Here is the script:

#MenuTitle: Remove Images
# -*- coding: utf-8 -*-
Deletes placed images from selected glyphs on all layers.

import GlyphsApp
Font = Glyphs.font
selectedLayers = Font.selectedLayers

def process( thisGlyph ):
	deleteCount = 0
	for thisLayer in thisGlyph.layers:
		if thisLayer.backgroundImage:
			deleteCount += 1
	return deleteCount


print "Removing images in %s selected glyphs ..." % len( selectedLayers )

for thisLayer in selectedLayers:
	thisGlyph = thisLayer.parent
	numberOfDeletedImages = process( thisGlyph )
	if numberOfDeletedImages:
		plural = 0
		if numberOfDeletedImages > 1:
			plural = 1
		print "  Deleted %i image%s in %s." % ( numberOfDeletedImages, "s"*plural, )

if thisLayer.isMasterLayer:
1 Like

Thank you Rainer!

1 Like