I need to resize texture image files after COLLADA Export in Sketchup Ruby.
Is there a way to read images (PNG, JPG) from disk, resize them and save them back to disk using plain Sketchup Ruby API?
I know how to do the file read/write, just have no idea about the “image decode, resize, encode” -part.
Most image resize examples I’ve found involve some image processing library or gem that is not available in Sketchup ruby distribution.. Would be nice to have a portable solution that would be easy to distribute with my SU Ruby plugin.
The SketchUp Ruby API doesn’t include methods to manipulate images directly.
You can create materials in the model which uses textures, but not just load an image resource.
There is a method you might be able to use:
Material.write_thumbnail(SU8M1+), based on your description you could iterate over the materials in the model and export thumbnails.However, the method has an very annoying limitation:
(More info on material in SketchUp: http://www.thomthom.net/thoughts/2012/03/the-secrets-of-sketchups-materials/#material-thumbnails)
To get real control over images when developing SketchUp plugins you do unfortunately need to use a third party library.
You can look at the plugin “Texture Resizer” by Aerilius who’s done a lot of work in this area. http://sketchucation.com/forums/viewtopic.php?f=323&t=40720#p360679