Jpg textures in *.skp
-
hmm... I wrote a PNG extractor once, and all I had to do was look for the PNG signature. Doing a quick look at a .skp file with two JPG textures I searched for the SOI (0xFF, 0xD8) and found both.
As for the structure of the .skp files - no one knows. No public records. I have spent some time looking at it but there is so many variables that reading it reliable is difficult.
-
@thomthom said:
SOI (0xFF, 0xD8) and found both.
Yes, 0xFF, 0xD9 and (transforming always in lowcase) "tp:","j" and "if" in the range of the following bytes...
Thanks, at this time one problem seems to be unsolvable.The start point of the name of the default textures, because it have not "" before. I must to write a filenames table...
But due the garbage the scan has not 100% certainty.
Thanks! -
Aren't you going about it the hard way?
The Ruby API already has 'texturewriter
' tools which let you export all of the model's materials textures as correct image files - jpg, png etc.
There are several examples of 'texturewriter
' use on the forum...
You can also extract an Image's 'image' as that part of an image-file in a a material that's applied to a face in a special kind of 'uneditable' definition...
You will have great difficulty extracting images otherwise as a material is in a skm which is a compressed file format. -
@soldatino said:
Yes, 0xFF, 0xD9
D9 ? - from what I find ont he JPEG format it's D8... ??
@soldatino said:
and (transforming always in lowcase) "tp:","j" and
what are you transforming to lower case? Isn't this something you should compare on a byte level?
@soldatino said:
The start point of the name of the default textures, because it have not "" before. I must to write a filenames table...
But due the garbage the scan has not 100% certainty.Are you looking for more than just the JPEG data? Are you also trying to get the texture filename?
Getting just the JPEG data extracted should be possible to reliably do - but if you're trying to get other meta data out of the .skp, that might be more troublesome - depending on what you try to extract. -
@tig said:
The Ruby API already has '
texturewriter
' tools which let you export all of the model's materials textures as correct image files - jpg, png etc.This only works on the currently open model.
@soldatino said:
I wrote a code using my preferred programming language that saves all the jpg files of the skp
From this I gathered that he was trying to extract the JPEG data from an external application.
Saying that though, there is an SDK to read and write .skp files: http://code.google.com/apis/sketchup/docs/downloadsdksubmit.html
-
@thomthom said:
@soldatino said:
Yes, 0xFF, 0xD9
D9 ? - from what I find ont he JPEG format it's D8... ??
@soldatino said:
and (transforming always in lowcase) "tp:","j" and
what are you transforming to lower case? Isn't this something you should compare on a byte level?
@soldatino said:
The start point of the name of the default textures, because it have not "" before. I must to write a filenames table...
But due the garbage the scan has not 100% certainty.Are you looking for more than just the JPEG data? Are you also trying to get the texture filename?
Getting just the JPEG data extracted should be possible to reliably do - but if you're trying to get other meta data out of the .skp, that might be more troublesome - depending on what you try to extract.I apologize, my english is bad.
0xFF, 0xD8 are the bytes at the start of the file, that continues with some bytes including "j" and "if" for sure, but h-l case depending by the editor that generated the jpg.
0xFF, 0xD9 are the last bytes of the file and are important because I don't know the filesize.
After these bytes, SU writes a information block, where the presence of slashes and ".jpg" string means that the jpg original file was in the PC of the creator, differently, if they are not and you find "tp:" the file was downloaded from the web, and there is a url instead of a filename. If you find nothing and only ".jpg", the file is a SU texture in his folder.
Warning : the "name" is written n+chr$(0)+a+chr$(0)+m+chr$(0)+e+chr$(0)+. ......etc
Thank Tig and ThomThom for the infos, I will search for the API also. -
Perhaps you're getting confused by the fact that the strings are widechars (2 bytes per character).
-
@soldatino said:
0xFF, 0xD9 are the last bytes of the file and are important because I don't know the filesize.
There is an signed/unsigned integer in the four bytes immediately before SOI that gives you the size of the image.
(which is lucky as the .skp format often don't give any indication of the various sizes of its blocks.)
@soldatino said:
Warning : the "name" is written n+chr$(0)+a+chr$(0)+m+chr$(0)+e+chr$(0)+. ......etc
This is because part of the .skp format is in Unicode format. (Though not all strings.)
I've attached my notes on the .skp format. It's far from complete, and is in some places wrong. (I think I found some new info last time I looked which I haven't written down in these notes yet.)
Also attached is a 010 template I use when poking around in the .skp format.
-
@thomthom said:
@soldatino said:
0xFF, 0xD9 are the last bytes of the file and are important because I don't know the filesize.
There is an signed/unsigned integer in the four bytes immediately before SOI that gives you the size of the image.
The size of image or the offset of the end of jpg file?
@thomthom said:
I've attached my notes on the .skp format. It's far from complete, and is in some places wrong. (I think I found some new info last time I looked which I haven't written down in these notes yet.)
Also attached is a 010 template I use when poking around in the .skp format.Really interesting! I am finishing the first version (a couple of hours for interface) of my jpg extractor then I will study it!
-
fwiw, you might want to check out file juicer for ideas:
http://echoone.com/filejuicer/that apps extracts all image files from a .skp (file thumbnails, scene thumbnails, textures, images etc.) [and it will extract other file types if they happen to be in the .skp]
i made a post about this before in which i posted a sample output from a juiced .skp:
http://forums.sketchucation.com/viewtopic.php?p=276979#p276979[edit] hmm.. maybe it's osx only.. surely there's something similar for windows?
-
@soldatino said:
The size of image or the offset of the end of jpg file?
The size. After that 4 byte int, just read the next immediate chunk given that size and you should have your image.
-
@unknownuser said:
fwiw, you might want to check out file juicer for ideas:
http://echoone.com/filejuicer/that apps extracts all image files from a .skp (file thumbnails, scene thumbnails, textures, images etc.) [and it will extract other file types if they happen to be in the .skp]
Thaks, I think to add other types of files also. Usually they have the header that it is more legible than the JPG...
-
ok, it'is working
http://www.imitidicthulhu.it/skp2jpg.zip
probably a lot of bugs ...
very slow on large file (I will improve the scan using blocks-buffer...)
and the filenames of jpg supplied by SketchUp have to clean from some starting characters (it need a table of SU files)ps: at the end of each jpg there is garbage (SU notes)... but usefull for the debug, and it does not corrupt the file...
update 002 extract fast!
update 003 SU default Materials filenames fixed -
require 'sketchup.rb' if( not file_loaded?("skp2jpg.rb") ) UI.menu("Plugins").add_item("skp2jpg execute"){UI.openURL("skp2jpg.exe")} end file_loaded("skp2jpg.rb")
this plugin run skp2jpg.exe in the drawing session (checked on XP)
skp2jpg.exe and 3Drgb.dll have to be in system32 or windows -
Current skp2jpg.exe version 5, same link
http://www.imitidicthulhu.it/skp2jpg.zip
allows you to extract PNG files also (checked with few SU models...)EDIT version 5b (large PNGs slow fixed)
-
skp2jpg Updated at version 7a
Some lost jpg now are succesfully extracted
All jpg filenames are saved, instead of xxx_num.jpg -
bug found!
if the model has two files primarily stored by the autor in two different folders but with the same filename the program is confused and fails attempting to save the two files ... I am working about it to fix this unusual but possible recurrence..[EDIT] fixed in vers 0.0.8
-
Added in the zip the stand alone utility T-Magnifier.
You can see better the selected picture that you study and/or edit.
This is the v.0, next I will add the Extract button about the current picture.
This trick requires SU 8, English or Italian languages
(skp2jpg.exe extracts actually only all the files of the SKP)
NOTE: not checked with SU version 8 Pro.
-
another FIX in vers 0.0.8a http://www.imitidicthulhu.it/skp2jpg.zip
case : missing path, jpg file found in SU RootDir(?)
no slashes found, possible prefix to filename (at end of SU file block) = &FF &FE [&??] [&??]
it seems working, anyway a possible error involves only the exact filename... -
Yea - occasionally texture filenames doesn't have a path. The ones that bundle with SU never does.
Advertisement