[Plugin] Texture Resizer (1.5.6) — updated 15.05.2013

[Plugin] Texture Resizer (1.5.6) — updated 15.05.2013

Postby Aerilius » Tue Oct 18, 2011 12:39 pm

This Plugin allows to downsample all textures in the model / selection. This can be useful if you want to quickly share a file that is too big because of extensive textures, or you used photos directly from the camera and want to batch-downsample to an optimal resolution.

As for Google Earth: a to harsh compression isn't necessary (use it only downsize textures to 1024px or meet the 10MB limit) since Google Earth has its own optimization and might in future use higher quality textures.
TextureResizer.gif


Download: cross-platform, requires ImageMagick
ae_TextureResizer_1_5_6.rbz
  •  Windows  You can download ImageMagick from the official site or from here. If necessary, the Plugin will ask you where ImageMagick has been installed.
    ImageMagick.zip
  •  Linux/Wine  Your distribution most likely comes with native ImageMagick preinstalled (faster), if not install it from the repositories or install the Windows version into Wine.
  • OS X You can download it from the official site or install/compile it using MacPorts or Homebrew.
 Alternative download:  OS X (10.4+), no need for ImageMagick. This version does not have the crop/rotate feature.
ae_TextureResizer_1_5_6_OSX.rbz



Version: 1.5.6

Date: 15.05.2013

Usage:
(Menu) Plugins Resize Textures

With nothing selected, it resizes all materials; with selection you can choose whether you want only the selected faces to be affected (only in selection) or whether the selected materials should be resized (in the whole model).

Resizing can be performed either to a given percentage, or optimized to a specific resolution (pixel per meter) or optimized for a specific view (using the plugin Goldilocks if it is installed).

screenshot_dialog.png


Textures can now be cropped to the area that is actually used in the model. This way you can get rid of sky or monochrome background of texture maps. If desired, the plugin rotates the crop boundary so that it fits best:
screenshot_crop.png
1
Last edited by Aerilius on Wed May 15, 2013 8:22 pm, edited 50 times in total.

Aerilius 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer

Postby Rich O Brien » Tue Oct 18, 2011 12:41 pm

That's very clever :thumb:

I'll say thanks on behalf of those who've downloaded so far. Keep up the great work.
0
There's a frontroom and a backroom....reverse faces
User avatar
Rich O Brien 
Administrator
 

Re: [Plugin] Texture Resizer

Postby tridem » Tue Oct 18, 2011 1:17 pm

Great idea :thumb:
0
User avatar
tridem 
 

Re: [Plugin] Texture Resizer

Postby Ben Ritter » Tue Oct 18, 2011 1:35 pm

Thank you! :D
0

Ben Ritter 
 

Re: [Plugin] Texture Resizer

Postby saturne45 » Tue Oct 18, 2011 2:29 pm

Very good plugin, thank you very much.
0

saturne45 
 

Re: [Plugin] Texture Resizer

Postby a4chitect » Tue Oct 18, 2011 2:35 pm

thank you very much !!
0

a4chitect 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer

Postby pitrak » Tue Oct 18, 2011 2:49 pm

Simply amazing! I was just going to look up a way to reduce texture sizes on a 18MB SU project. I open Sketchucation and this is the first thread of the bunch :shock:

Thanks for this, I'll give it a go and let you know how it turns out!
0

pitrak 
 

Re: [Plugin] Texture Resizer

Postby Aerilius » Tue Oct 18, 2011 3:14 pm

Thanks for the comments!
If someone would be interested to help me get it work on OSX, that would be great.
0

Aerilius 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer

Postby pitrak » Tue Oct 18, 2011 3:38 pm

The % reduction seems to work great. File size went from 18mb to 10mb and quality is still quite ok.

But when I tried the 20pix/meter option I got different results. I posted a cropped screenshot of before and after the reduction. As you can see the right facade remains unaltered, while the new one and the left neighbour are reduced a lot.

I've used 'make unique texture' on some of these, maybe that's the problem?

BTW, this could work very well with "Component edit window". You select a component, open in another window, change texture size and bring it back. Like that you have control over the different parts of your project.
0

pitrak 
 

Re: [Plugin] Texture Resizer

Postby leedeetee » Tue Oct 18, 2011 5:17 pm

This will be a superb tool for those who like to do an odd Google Earth model, and model with hires photographs and quickly optimise them for GE. Nice one. :thumb:
0
User avatar
leedeetee 
Premium Member
Premium Member
 

Re: [Plugin] Texture Resizer

Postby Aerilius » Tue Oct 18, 2011 5:18 pm

During my testing, I also had sometimes cases where the resolution depending option had different results but I thought it was fixed now.
There are two possibilities:
  • The plugin only takes into account the texture dimensions as they are in the materials dialog. If the texture has been scaled using the texture pins, it won't work (for now). Just for a test, you can check this by right-click on face -> reset texture.
  • If an error happens during conversion, it won't replace the texture.
I'll do some testing later.

Also, you can use any other number instead of 20px/m if you like ;)
0

Aerilius 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer

Postby gullfo » Wed Oct 19, 2011 12:13 am

0
User avatar
gullfo 
 

Re: [Plugin] Texture Resizer

Postby Aerilius » Wed Oct 19, 2011 12:11 pm

Sorry, I have seen that one too ( ;) ), but Mac people usually compile that download (or install it via MacPorts). I haven't found yet a pre-compiled portable single-file "ImageMagick.app".
0
Last edited by Aerilius on Wed Oct 19, 2011 1:34 pm, edited 1 time in total.

Aerilius 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer

Postby AcesHigh » Wed Oct 19, 2011 1:13 pm

this is a great plugin for GoogleEarth modellers!
0

AcesHigh 
 

Re: [Plugin] Texture Resizer

Postby driven » Wed Oct 19, 2011 3:09 pm

Aerilius wrote:I haven't found yet a pre-compiled portable single-file "ImageMagick.app".


I haven't either, and I've been looking for 2 years, MacPorts is a nightmare and compiling from source fraught with error.

I have installed lots of other stuff through Terminal, but ImageMagick and GraphisMagic evade me.

On OSX 10.5.[*] the problems stem from a poor implementation of X11 in the Xcode bundle,
so you need the appropriate version from X11 to start with. [If 'InkScape.app' works, X11 has been updated by Apple/Xcode for you.]

All the other dependancies are also OSX Version specific, but not necessarily in a straightforward way.

I'll have another dig, but I'm not sure I can help.

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer

Postby Bertier » Wed Oct 26, 2011 1:31 pm

it's Aerilius first plugin...

he is a super Earth modeler !

I know he's got some awesome plugin to come

he is my hero !
0

Bertier 
 

Re: [Plugin] Texture Resizer

Postby thomthom » Wed Oct 26, 2011 1:43 pm

I didn't notice this plugin until now.

I see you're using ImageMagik - if you are willing to require that the users have a recent SketchUp version ( SketchUp 8 Maintenance Release 1 ) then you can use Material.write_thumbnail to write out smaller versions of the material's texture.

http://code.google.com/apis/sketchup/do ... _thumbnail

Cross platform, native to SketchUp, and doesn't require dependencies other than an updated SketchUp 8M1.
1
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer

Postby Aerilius » Wed Oct 26, 2011 3:40 pm

Thanks for that tip! I haven't found it or thought about it. That's probably the most straight-forward way to do the current features cross-platform and inside SketchUp. I'll test how it works with different resolutions.
On the other side, ImageMagick is very powerful to do more advanced image manipulation (I've thought about cropping, distortion and more features) and for higher-quality output (Sinc-Lanczos).
0

Aerilius 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer

Postby thomthom » Wed Oct 26, 2011 3:44 pm

Yea, it's much more limited in the output. You cannot specify compression level for JPEGs for instance. And the output must be at least 1px smaller than the original.

But it's a nice little addition to the API that might be useful.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer

Postby Aerilius » Wed Oct 26, 2011 6:53 pm

I tested Material.write_thumbnail and it failed too often. It seems there are absurd limitations. The resolution argument only accepts values that are 1px smaller than the smaller length of [width, height], but "resolution" is always applied as the maximum length. Thus an image of 1024*33 can only be resized with resolution=32, whereas resolution=31 fails because 31*(33/1024) < 1, so you never can get 500*16.
0
Last edited by Aerilius on Wed Oct 26, 2011 9:59 pm, edited 1 time in total.

Aerilius 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer

Postby thomthom » Wed Oct 26, 2011 7:26 pm

Ah yea... that is an annoying limitation...
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer

Postby Whaat » Fri Oct 28, 2011 12:21 am

Thanks! I've been wanting a plugin like this. Nice work!
0

Whaat 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer (1.1.0) — 28.10.2011

Postby schnydix » Fri Oct 28, 2011 9:32 pm

thank you very much realy great work respect
i hope google see whats going on here on the plugins front :o
0

schnydix 
 

Re: [Plugin] Texture Resizer (1.1.0) — 28.10.2011

Postby driven » Sat Oct 29, 2011 1:34 am

Hi Aerilius,

have managed a Mac install of ImageMagicks using Homebrew http://mxcl.github.com/homebrew/ the nice thing is it sorts out all the dependencies for the system it's running on...
I now get this in Terminal,
$ which convert
/usr/local/bin/convert

but I get your 'install advice' in SU

also, I get... I can pull more details if you want...
$ convert -v
Version: ImageMagick 6.7.1-1 2011-10-27 Q16 http://www.imagemagick.org

$ convert -list type
Bilevel
ColorSeparation
ColorSeparationMatte
Grayscale
GrayscaleMatte
Optimize
Palette
PaletteBilevelMatte
PaletteMatte
TrueColorMatte
TrueColor


I had to completely get rid of MacPorts before I had any joy compiling [and reinstall my system ruby that MacPorts had modified...]

I'll try some things Saturday night, soo if you have any ideas let me know.

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer (1.2.0) — 01.11.2011

Postby driven » Tue Nov 01, 2011 5:01 pm

hi Aerilius,

the default text is still not appearing and neither is any obvious "Goldilocks' integration...

thanks for the thanks, but it's all your hard work, I'm just playing and making your life harder....

john
PS. can you reply in the thread as well, I don't get the notifications when you just edit the head message,
is that standard?
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer (1.2.0) — 01.11.2011

Postby Aerilius » Tue Nov 01, 2011 6:10 pm

the default text is still not appearing and neither is any obvious "Goldilocks' integration...

Both indicate that I didn't get the javascript started in Safari. I hope I fixed it now in 1.2.1
0

Aerilius 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer (1.2.1) — 01.11.2011

Postby driven » Wed Nov 02, 2011 3:49 pm

still a negative on that captain...

this is pulled from SU
Code: Select all
<html><head>
<title>Resize Textures in model</title>
<meta http-equiv="content-type" content="text/html; charset = UTF-8">
<meta http-equiv="MSThemeCompatible" content="Yes">
<style type="text/css">
body{background-color:Window;color:WindowText;font:message-box;user-select:none;cursor:default;overflow:hidden}
input{vertical-align:middle;}
fieldset{text-indent:0px!important;margin-bottom:10px;margin-right:0px!important}
input[type=text]{background-color:Window;border:1px ButtonShadow solid;margin:1px;padding:0px}
input[type=text][disabled]{background-color:ButtonFace;border:1px ButtonShadow solid}
input[type=text].num{text-align:right;width:40px;padding-right:2px}
button{min-width:70px;font:message-box;color:ButtonText;padding:1px}
.buttons{float:right;margin-top:10px;padding:0px}
#body{position:absolute;left:0px;top:0px;margin:0px;padding:20px;overflow:hidden}
#options ul{list-style-type:none;margin:0px;padding:0px}
#options>ul, #options fieldset>ul{display:block!important;}
#options li{display:block!important}
#options ul ul{display:inline!important}
#options ul ul li{display:inline!important;padding-left:15px!important}
.progress-bg{position:absolute;left:0px;top:0px;z-index:1000;margin:0px;width:100%;height:100%;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAA1JREFUCNdjCAkJqQcAA3gBfJ4UYBwAAAAASUVORK5CYII=)}
.progressbar{position:absolute;left:50%;top:50%;z-index:1001;width:140px;height:80px;margin-left:-70px;margin-top:-40px;padding:1px;background:Window;border:Window 1px inset;appearance:progressbar;-moz-appearance:progressbar;-webkit-appearance:progressbar}
.progressbar-state{width:48px;height:48px;background:Highlight;margin-left:46px;margin-top:8px;background:url(loadinfo.gif) no-repeat}
#progressbar-action{position:absolute;top:50%;left:0px;margin-top:15px;width:100%;text-align:center;color:WindowText}
</style>
</head>

<body id="body">
<form id="options">
  <fieldset>
      <legend>Resizing method</legend>
    <ul>
      <li>
        <input type="radio" name="method" value="percent" id="method-percent">
        <label for="method-percent" title="Calculates the dimensions depending on the textures original pixel size.">Percentage:</label>
        <ul>
          <li>
            <input type="text" name="percentage" value="" class="num">&nbsp;%
          </li>
        </ul>
        <br>
        <input type="radio" name="method" value="resolution" id="method-resolution">
        <label for="method-resolution" title="Calculates the dimensions depending on the metric size of the texture as it is used in the model.">Depending on real-world resolution:</label>
        <ul>
          <li>
            <input type="text" name="resolution" value="" class="num">&nbsp;pixel&nbsp;per&nbsp;meter
          </li>
          <br>
          <li>
            <input type="checkbox" name="resolution-by-faces" id="resolution-by-faces">&nbsp;<label for="resolution-by-faces" title="This gives a very accurate and consistent texture resolution, but is slow. If you deal with 20000+ polygons, you might uncheck this.">consider texture dimensions on each single face</label>
          </li>
        </ul>
        <style type="text/css" id="style0">.goldilocks{display:none!important}</style>
        <br class="goldilocks">
        <input class="goldilocks" type="radio" name="method" value="goldilocks" id="method-goldilocks">
        <label class="goldilocks" for="method-goldilocks" title="Calculates the dimensions depending on the current viewport using the plugin Goldilocks.">Goldilocks resolution:</label>
        <ul class="goldilocks">
          <li>
            <input type="text" name="goldilocks-resolution" value="" class="num goldilocks">
          </li>
        </ul>
      </li>
    </ul>
  </fieldset>
  <ul>
    <li>
      <input type="checkbox" name="limit" id="limit">
      <label for="limit" title="Optional. No width or height shall be longer/shorter than the following limit:">Limit:</label>
      <ul>
        <li>
          maximum&nbsp;size&nbsp;<input type="text" name="max" value="" maxlength="4" class="num">&nbsp;px,
        </li>
        <li>
          minimum&nbsp;size&nbsp;<input type="text" name="min" value="" maxlength="4" class="num">&nbsp;px
        </li>
      </ul>
    </li>
    <li>
      <input type="checkbox" name="compression" id="compression">
      <label for="compression" title="Optional. Compresses all jpeg textures to the following percentage. If not set, the original texture's quality setting will be used.">Compress jpeg textures?</label>
      <ul>
        <li>
          quality <input type="text" name="jpeg-quality" value="" title="recommended: not lower than 75" maxlength="3" class="num">&nbsp;%
        </li>
      </ul>
    </li>
  </ul>
  <input type="hidden" id="results">
</form>
<span class="buttons">
  <button onclick="javascript:returnOptions()">OK</button> &nbsp; <button onclick="window.location='skp:cancel'">Cancel</button>
</span>

<div class="progress-bg" id="overlay" style="display:none">
  <div class="progressbar"><div class="progressbar-state" id="progress"></div><div id="progressbar-action"> &nbsp; &nbsp; Processing . . .</div></div>
</div>

<script type="text/javascript">
function $(id){return document.getElementById(id)}
function inObject(value, object){for(i in object){ if(i==value){return true} };return false}
function puts(s){window.location = 'skp:puts@"'+s+'"'}

// resize the height of the webdialog so that everything fits well
// measures the html's dimensions
function resizeHeight() {
  window.location = 'skp:resizeHeight@['+($("body").clientWidth|$("body").scrollWidth)+','+($("body").clientHeight|$("body").scrollHeight)+']';
}

// disable input elements inside element <el>
// a parent container contains a checkbox/several radio buttons
// and for each a list <ul> with child inputs
function toggleDisabled(el){
  return function(){
    var p = el.parentNode.childNodes;
    // one checkbox or several radio buttons inside the parent container
    var checkradio = [];
    for(var i=0;i<p.length;i++){ if(p[i].nodeName=="INPUT"&&(p[i].type=="checkbox"||p[i].type=="radio")) checkradio.push(p[i]) };
    // corresponding containers with lower-level inputs that should be disabled/enabled
    var ul = [];
    for(var i=0;i<p.length;i++){ if(p[i].nodeName=="UL") ul.push(p[i]) };
    for(var i=0;i<checkradio.length;i++){
      if(!ul[i]){continue}
      // enable all child inputs
      if(checkradio[i].checked==true){
        var inputs = ul[i].getElementsByTagName("input");
        for(var j=0;j<inputs.length;j++){inputs[j].removeAttribute('disabled')}
      } else{
      // or disable all child inputs
        var inputs = ul[i].getElementsByTagName("input");
        for(var j=0;j<inputs.length;j++){inputs[j].disabled=true}
      }
    }
  }
}

function startProgress(){
  $("overlay").style.display="block";
}

function endProgress(){
  o=$("overlay").style.display="none";
}

function start(object){
  // load defaults
  // identifies input elements when their name matches the default option's name
  var inputs=$("options").getElementsByTagName("input");
  for(var j=0;j<inputs.length;j++){var i=inputs[j];
    if( (inObject(i.name,object)) && (i.type=="radio" && object[i.name]==i.value || i.type!="radio") ){
      if(i.type=="checkbox"){ i.checked = object[i.name];
      } else if(i.type=="radio"){ i.checked = true;
      } else{ i.value = object[i.name] }
    }
    var t=toggleDisabled(i); t();
    i.onclick=toggleDisabled(i);
  };
  void(0);
}

// this is the magic function
// it returns all user input
// checkboxes are identified by their "name" attribute and return true/false
// radio buttons are identified by their "name" and return the string of the "value" attribute
function returnOptions(){
  var user_input=[];
  inputs=document.getElementsByTagName("input");
  for(var j=0;j<inputs.length;j++){i=inputs[j];
    if(i.type=="checkbox"&&i.name&&!i.disabled){user_input.push('"'+i.name+'" =\> '+i.checked)}
    else if(i.type=="radio"&&i.name&&i.checked&&!i.disabled){user_input.push('"'+i.name+'" =\> "'+i.value+'"')}
    else if(i.type=="text"&&!i.disabled&&i.className.search(/\bnum\b/i)!=-1){user_input.push('"'+i.name+'" =\> "'+parseInt(i.value)+'"')}
    else if(i.type=="text"&&!i.disabled){user_input.push('"'+i.name+'" =\> "'+i.value+'"')}
  }
  var user_input="{"+user_input.join(", ")+"}";
  $("results").value=user_input;
  window.location='skp:receiveOptions';
}

// init
function init(){
  window.location='skp:init@';
  // measures the window's inner dimensions
  window.location='skp:windowInner@['+(window.innerWidth|document.documentElement.clientWidth)+','+(window.innerHeight|document.documentElement.clientHeight)+']';
  window.onresize=resizeHeight;
}
init()
</script></body></html>

reloading dose nothing different... except mess up the resize the first time but that's the SU topdown nonsense...

I just tried
Code: Select all
<button onclick="puts(s)">Defaults</button>
and get ReferenceError: Can't find variable: s
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer (1.2.2) — 02.11.2011

Postby driven » Sat Nov 19, 2011 3:27 am

1.2.2 is working a treat on Mac 10.5.8 so I did a test with the now integrated Goldilocks settings.

for a test I grabbed a 'Velux slideshow' from the warehouse, ran goldilocks to see what the texture sizes were

ran Texture Resizer set at 4 and pulled 0.2MB out of the file-size, then re-ran at 1.2 and got a small additional reduction in size of 0.1MB.

The original was only 4.1MB so reducing it to 3.8MB without any noticeable degradation in 3-4 mins is pretty slick.

I did have one projected texture that needed re-positioning.

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer (1.2.3) — 18.11.2011

Postby driven » Sat Nov 19, 2011 3:46 am

hi,

here's the latest mac screenshot, after I added that 's'.....

'.png


john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Texture Resizer (1.2.3) — 18.11.2011

Postby Aerilius » Sat Nov 19, 2011 4:31 am

It finally looks really great, Thanks for all your help!
It's probably time to make a real Ruby Webdialog toolkit so that webdialogs don't look anymore like websites, but like native OS dialogs.

driven wrote:I did have one projected texture that needed re-positioning.

I have no idea what could cause this. The plugin doesn't touch UV coordinates but just replaces the texture images. Since SketchUp changes the aspect ratio and scale after re-importing, the plugin has to override it again with the old scale (it should work, but maybe there is a problem). Can you give me a link to the Velux model, then I can have a look tomorrow?
0

Aerilius 
PluginStore Author
PluginStore Author
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Next


 

Return to Plugins

Who is online

Users browsing this forum: martalexxx08 and 60 guests

Visit our sponsors: