-
-
Save davidlatwe/29a159caa98f5fecf4a8634d7d9532f3 to your computer and use it in GitHub Desktop.
Resize textures using python
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