Extract Material thumbnail?
-
Another project stomped due to lacking API. X_x grrr...
The thing is- I don't want to extract the full texture. They can be very large.
I need to get the thumbnail for my recreation of the Material browser. I don't want to extract 50 large textures and send it to the webdialog. That would just slow it right down - plus take up extra disk space.The thumbnails is what I need. They are small enough so you can pass them directly to the webdialog without saving them to disk - using data URIs which IE8 finally support, provided they are under 32KB.
-
Its stored in "doc_thumbnail.png" in the SKM file.
But can we see you "throwing a fit" for entertainment value?
-
@adamb said:
But can we see you "throwing a fit" for entertainment value?
Why yes you may. I can manually get the thumbs from an skm file - but not from Ruby during run time.
So stand by for a fit.
-
If you have the SDK you'll see there are methods for getting/saving thumbnails [url]file:///C:/Program%20Files/Google/Google%20SketchUp%207/sdk/SkpReader/documentation/interface_i_skp_thumbnail_provider.html[/url] [path might differ on your PC]
But you'll then need to compile a C++ applet to give the new methodmaterial.thumbnail
!
-
But isn't that thumbnails for .skp files? Like
Sketchup.save_thumbnail
http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/sketchup.html#save_thumbnail
-
The think that SDK's
ISkpThumbnailProvider
code is applicable to any object supporting a thumbnails - like Components and Materials... -
And this C++ voodoo can be used at run-time?
-
Just open the file from Ruby and rip out what you want, whats the problem?
-
I think you'd need to make an add-on that loads at startup that provides extra methods like the Exporters do like Skp2Acad.dll [presumably something else on a Mac!]- in this case say export(material.thumbnail,"filepath")
Not sure - it's a bit outside my remit............
You can also find the material's texture inside the SKP file's data but then getting it's thumbnail and the 'bits' is beyond me... -
@adamb said:
Just open the file from Ruby and rip out what you want, whats the problem?
But how - how do we find the particular material, then its texture and then its thumbnail within the mess of SKP data...
-
@adamb said:
Just open the file from Ruby and rip out what you want, whats the problem?
Because that would require the user to save the model before the script would be able to extract the thumbnails.
As mentioned - I'm trying to make a replacement for the material browser - so I need to get the material thumbnails at run time from the open model. -
@thomthom said:
Because that would require the user to save the model before the script would be able to extract the thumbnails.
Also - material thumbnails doesn't appear to be stored in the .skp file...
-
The material thumbnails are stored in the .SKM files [which is actually '.ZIP' files].
You can export a material's texture's image-file quite easily using existing API methods... and use that as your image... OR extract the thumbnail from the .SKM file as if it were a 'zip' using Ruby 'zip' methods'... -
@tig said:
You can export the material's texture's image-file quite easily using existing API methods
Original size - which might be huge. Not ideal for a material browser which would then load lots of full size images and only display it at a fraction of its size.@tig said:
OR extract the thumbnail from the file as if it were a 'zip' using ruby 'zip' methods'...
But there isn't a way to get in-model materials exported as .skm via Ruby, is it? -
If you get a 'large' image there are Ruby tools to down-size it into a thumbnail ???
http://rmagick.rubyforge.org/
http://snippets.dzone.com/posts/show/3621
http://oldwiki.rubyonrails.org/rails/pages/HowtoCreateThumbnailImages
etc etc............
Advertisement