Skip to content

Instantly share code, notes, and snippets.

@sambvfx
Last active January 29, 2016 17:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sambvfx/464093a03901eb7304ae to your computer and use it in GitHub Desktop.
Save sambvfx/464093a03901eb7304ae to your computer and use it in GitHub Desktop.
Update selected images in Mari's Image Manager
import os
from collections import defaultdict
# FIXME: store these dependencies on the image (maybe a callback exists for this?)
procedurals = defaultdict(list)
for geo in mari.geo.list():
for channel in geo.channelList():
for layer in channel.layerList():
if layer.isProceduralLayer() and 'TileImage' in layer.proceduralParameters():
procedurals[layer.getProceduralParameter('TileImage')].append(layer)
for image in mari.images.selected():
if not os.path.exists(image.filePath()):
continue
rimage = mari.images.open(
image.filePath(), image.colorspaceConfig(),
mari.images.IMAGE_PRE_MULTIPLY_ALPHA, '_tmp')[0]
if image.width() == rimage.width() and image.height() == rimage.height():
image.copyFrom(rimage)
image.makeThumbnail()
for layer in procedurals.get(image.filePath(), []):
layer.setProceduralParameter('TileImage', image)
rimage.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment