Skip to content

Instantly share code, notes, and snippets.

@SEVEZ
Last active September 7, 2017 17:49
Show Gist options
  • Save SEVEZ/8b47e804ef8826851263 to your computer and use it in GitHub Desktop.
Save SEVEZ/8b47e804ef8826851263 to your computer and use it in GitHub Desktop.
Resize textures using python #Util
import maya.cmds as cmds
import maya.OpenMaya as om
fileNodes = cmds.ls(sl=1)
width = 1024
height = 1024
image = om.MImage()
for i in fileNodes:
filePath = cmds.getAttr(i+'.fileTextureName')
image.readFromFile ( filePath )
image.resize( width, height, False )
image.writeToFile( filePath.split(".")[0] +'_resized.png', 'png')
# replace file textures with resized images
cmds.setAttr(i+'.fileTextureName', filePath.split(".")[0]+'_resized.png', type='string')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment