Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read/extract *.skp files thumbnails. #65

Open
jiminy-billy-bob opened this issue Mar 20, 2018 · 16 comments
Open

Read/extract *.skp files thumbnails. #65

jiminy-billy-bob opened this issue Mar 20, 2018 · 16 comments

Comments

@jiminy-billy-bob
Copy link

@jiminy-billy-bob jiminy-billy-bob commented Mar 20, 2018

Feature request : a method to read/extract *.skp files thumbnails.
I think it would make most sense in the C API, but could also be very useful in the Ruby API.

@thomthom thomthom changed the title [Feature Request] Read/extract *.skp files thumbnails. Read/extract *.skp files thumbnails. Mar 20, 2018
@thomthom

This comment has been minimized.

Copy link
Member

@thomthom thomthom commented Mar 20, 2018

@jiminy-billy-bob - the returned object would be an ImageRep? (This can easily be saved to file if needed.)

@jiminy-billy-bob

This comment has been minimized.

Copy link
Author

@jiminy-billy-bob jiminy-billy-bob commented Mar 20, 2018

An ImageRep seems to be the logical way to go, yes.

@prachtan

This comment has been minimized.

Copy link

@prachtan prachtan commented Mar 20, 2018

Imho, it should be separated set of light-weight methods. (For thumbnails, file info, model GUID etc)

For example, if you'll have a 500MB skp file, SUModelCreateFromFile can take tens of seconds to extract only thumbnail (this will require full "read&parse" which may be pointless in most cases).

@thomthom

This comment has been minimized.

Copy link
Member

@thomthom thomthom commented Mar 20, 2018

That's a good point Piotr.

@DanRathbun

This comment has been minimized.

Copy link

@DanRathbun DanRathbun commented Mar 20, 2018

I think it would make most sense in the C API, but could also be very useful in the Ruby API.

@thomthom, @jiminy-billy-bob : The API already has an extract to file method ...

Sketchup::save_thumbnail( skpfilepath, imgfilepath )

The save_thumbnail method is used to generate a thumbnail for any SKP file
- not necessarily the loaded model.

... from that you should be able to load an Sketchup::ImageRep object.

Should the Sketchup::ImageRep class' constructor method be extended to allow specifying an SKP file as a load argument (that uses a model file's thumbnail image) ?

@DanRathbun

This comment has been minimized.

Copy link

@DanRathbun DanRathbun commented Mar 20, 2018

... and I see no C API equivalent.

@thomthom

This comment has been minimized.

Copy link
Member

@thomthom thomthom commented Mar 21, 2018

Huh! I never noticed there was a Sketchup::save_thumbnail( skpfilepath, imgfilepath ) in the API...

The doc description says it generates a thumbnail, I wonder if that is the case - or whether it simply extract the only that already exist...

@DanRathbun

This comment has been minimized.

Copy link

@DanRathbun DanRathbun commented Mar 21, 2018

I always thought it was the latter, but now that you mention it, and I reread the doc, it seems to imply the former.


This could be significant if the user has manually switched OFF the "Redefine thumbnail on save" option in Model Info > File. (Ref Issue: #14)

One coder might want the internal thumbnail even if it has not been updated (recently) as they may want what the user wants as the thumbnail.

Another coder may instead want a thumbnail of the current (latest) model view regardless of what the internal thumbnail image is. (The Ruby API has the Sketchup::Model#save_thumbnail which can work for this scenario if the scene is first changed to the desired scene. But again I could not find an equivalent C API function.)

@jiminy-billy-bob

This comment has been minimized.

Copy link
Author

@jiminy-billy-bob jiminy-billy-bob commented Mar 21, 2018

From my initial tests, the thumbnail seems to be extracted, not generated.
When switching of "Redefine thumbnail on save", the thumbnail is always the same.

In most cases, this is good news, as extracting is probably much faster than generating when dealing with very large files.

@DanRathbun

This comment has been minimized.

Copy link

@DanRathbun DanRathbun commented Mar 22, 2018

In most cases, this is good news, as extracting is probably much faster than generating when dealing with very large files.

I'd agree. It is a simple thing to extract raw existing data from a file, but quite a complex thing to render a view (or scene.)

And then (from what I can tell of the C API documentation,) the file access APIs never had any rendering capability, nor access to a "view" object like the live internal application API. (Otherwise ppl would have been trying to create their own SketchUp clone applications using the C SDKs. Over the years quite a few "hackers" have asked how to do it, or run SketchUp in "headless" mode.)

@thomthom thomthom added the logged label Aug 9, 2018
@thomthom

This comment has been minimized.

Copy link
Member

@thomthom thomthom commented Aug 9, 2018

Logged as SU-40217

@prachtan

This comment has been minimized.

Copy link

@prachtan prachtan commented Aug 7, 2019

@thomthom - regarding to #225

Maybe you could shed some light (as in the case of GUID) and share information on how to read a thumbnail manually? :)

I see that there is 'CDib' tag, followed by (DWORD) 0x4 (what's this?) then (DWORD)<size_in_bytes_of_thmb_png> and the thumbnail PNG...

@thomthom

This comment has been minimized.

Copy link
Member

@thomthom thomthom commented Aug 7, 2019

You're in luck, I'd been reverse engineering this for a .SKP template for 010 Editor:

It's a value to indicate filetype

image

@tiffjh63

This comment has been minimized.

Copy link

@tiffjh63 tiffjh63 commented Mar 10, 2020

@thomthom - could you share the template or a description of the SKP format in some other form.

@thomthom

This comment has been minimized.

Copy link
Member

@thomthom thomthom commented Mar 19, 2020

There is no formal description of the SKP format. What are you looking for?

@tiffjh63

This comment has been minimized.

Copy link

@tiffjh63 tiffjh63 commented Mar 27, 2020

The information in the parts of your template that aren't in that screenshot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.