Tif image loader

free scripts, plugins, models, textures
User avatar
clintonman
Captain
Posts: 5429
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Tif image loader

Post by clintonman »

tiffLoader.jpg
tiffLoader.jpg (42.1 KiB) Viewed 2800 times
Plugin to load tif format image files into workspace. Loads both compressed and uncompressed tif files. Based on the tifflib code, tiff library and utilities.

http://clintons3d.com/plugins/truespace ... tiffloader
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5214
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Tif image loader

Post by trueBlue »

Can this Tiff Loader be updated to use your plugin Open dialog with TIF as the only choice?
.
Tiff Loader.png
Tiff Loader.png (4 KiB) Viewed 1720 times
.

Code: Select all

var fso = new ActiveXObject("Scripting.FileSystemObject");
var util = System.CreateDO("Clintons3D Package/Utility functions");
var folder = "";
var filename = "";
folder = fso.GetParentFolderName(filename);
filename = fso.GetFileName(filename);
//fso method return of folder or filename is flawed when path is invalid/empty
//causes returned value of plugin to cause tS crash
if(folder=="") folder="";
if(filename=="") filename="";
//var defExt = "tga";
//var filter = "TGA (*.tga)~*.tga~EXR (*.exr)~*.exr~HDR (*.hdr)~*.hdr~Jpeg (*.jpg)~*.jpg~PNG (*.png)~*.png~TIF (*.tif)~*.tif~All Files (*.*)~*.*~~";
var defExt = "TIF";
var filter = "TIF (*.tif)~*.tif~All Files (*.*)~*.*~~";
var file = util.FileOpenDialog(folder, filename, filter, defExt);
The Tif Loader.RsObj has a Filename attribute
Not sure how to remove All Files and populate the Filename attribute with the returned path
Removed due to update
User avatar
clintonman
Captain
Posts: 5429
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Tif image loader

Post by clintonman »

New button added.

The way you wrote the popup you are limited to 1 tiff file in the scene, so if you want more than 1 you have to rename the node before loading another one.
Attachments
Tiff Loader.RsObj
(57.62 KiB) Downloaded 83 times
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5214
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Tif image loader

Post by trueBlue »

Thank you!
I tried removing the popup's Node.Delete, but I find, since multiple copies share the one Panel Frame, there is multiple copies left over in the scene
Do you have a better suggestion?
Couldn't a user Load and Save images from the same panel?
I tried using your plugin's Save As Dialog (v2) for trueSpace, but failed miserably!
Removed due to update
User avatar
clintonman
Captain
Posts: 5429
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Tif image loader

Post by clintonman »

I don't know how you're planning to use it, so no I don't have any suggestions. Don't even know why it's a popup.

Save as images has limited file formats, bmp, dds, hdr, jpg, png, dib, pfm.

Attached has working Save as Dialog(v2)
Attachments
Tiff Loader.RsObj
(58.29 KiB) Downloaded 77 times
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5214
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Tif image loader

Post by trueBlue »

clintonman wrote: 23 Apr 2022, 22:24 I don't know how you're planning to use it, so no I don't have any suggestions.
Don't even know why it's a popup.
Thanks again :bananathumb:
The popup is for users that have Link Editor phobia ;)
I take it, that you use it for importing and linking tif images to other bitmaps in the Link Editor?
That is still possible

There was an issue when switching to png in the dialog, it would not switch to png
Also, the File name: in the dialog was the name of the imported tif
IE: File name: MyImage.tif
When you save it that way, even though the dialog's Save as type: was bmp, the file saved is not good
So I added one line:
filename = "Image"
Here is the changes:

Code: Select all

var Filename = Node.Value("%THIS_NAME%", "Filename")
if(Filename == "") {return;}
var fso = new ActiveXObject("Scripting.FileSystemObject");
var util = System.CreateDO("Clintons3D Package/Utility functions");
var folder = "";
var filename = Node.Value("%THIS_NAME%", "Filename");
var defExt = "bmp";
var filter = "BMP (*.bmp)~*.bmp~DDS (*.dds)~*.dds~HDR (*.hdr)~*.hdr~Jpeg (*.jpg)~*.jpg~PNG (*.png)~*.png~";
filename = "Image"
var file = util.FileSaveAsDialog2(folder, filename, filter, defExt);
if(file) Library2.DlgGenericSave(file, "%THIS_NAME%/Image", 3);
It seems to work, unless you see something that is not correct
One thing to note is I omitted one Tilda ( ~ ) at the end
.
User avatar
clintonman
Captain
Posts: 5429
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Tif image loader

Post by clintonman »

From the original Save As Dialog, uses "~" as a delimiter between the description and the extension and end the string with 2 ~'s

So removing the extra ~ maybe it's ok or maybe it create problems later. I wouldn't take the chance.

It would be simpler to change the line

var filename = Node.Value("%THIS_NAME%", "Filename");

to

var filename = "";
or
var filename = "Image";
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5214
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Tif image loader

Post by trueBlue »

Thanks, I added the extra ~
One way I was using your TIF Loader is in YafaRay4tS as a TIF Viewer
User avatar
trueBlue
Captain
Posts: 5214
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Tif image loader

Post by trueBlue »

Just noticed that this does not show/open tiff images only tif
Edit: I fixed it
var filter = "TIF (*.tif)~*.tif~TIFF (*.tiff)~*.tiff~~";
Is the a way to show/open both in the File type:?
User avatar
clintonman
Captain
Posts: 5429
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Tif image loader

Post by clintonman »

trueBlue wrote: 26 Apr 2022, 00:23 Just noticed that this does not show/open tiff images only tif
Edit: I fixed it
var filter = "TIF (*.tif)~*.tif~TIFF (*.tiff)~*.tiff~~";
Is the a way to show/open both in the File type:?
Good question. Had to look it up. You use semicolon to list them

var filter = "TIF (*.tif;*.tiff)~*.tif;*.tiff~~";
the first half is displayed and can be anything you want - "TIF (*.tif;*.tiff)"
second half is the actual filter "*.tif;*.tiff"
Clinton Reese

http://clintons3d.com
Post Reply