Last active
September 7, 2017 17:49
-
-
Save SEVEZ/8b47e804ef8826851263 to your computer and use it in GitHub Desktop.
Resize textures using python #Util
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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