Skip to content

Instantly share code, notes, and snippets.

@davidlatwe
Forked from SEVEZ/resize_tex.py
Created March 7, 2017 06:31
Show Gist options
  • Save davidlatwe/29a159caa98f5fecf4a8634d7d9532f3 to your computer and use it in GitHub Desktop.
Save davidlatwe/29a159caa98f5fecf4a8634d7d9532f3 to your computer and use it in GitHub Desktop.
Resize textures using python
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