Peter Hiscocks
Peter Hiscocks

Reputation: 11

image create photo, spaces in filename

This command is the problem:

set imageCreated [image create photo backPhoto -file $imageName]

It fails for spaces in the file name, even when they are escaped with backslash.

aa-F-1s-ISO-2000.tiff works fine

aa F 1s ISO-2000.tiff causes error

aa\ F\ 1s\ ISO-2000.tiff causes error

Is this a bug in image create or am I doing something wrong?

Thanks - Peter

Upvotes: 0

Views: 108

Answers (1)

patthoyts
patthoyts

Reputation: 33203

It should work fine, as demonstrated below. (I used ImageMagick's convert program to get a TIFF file from a png):

% package require Tk
8.6.5
% package require img::tiff
1.4.2
% set filename "Screenshot from 2015-10-22 23:54:41.png.tiff"
Screenshot from 2015-10-22 23:54:41.png.tiff
% set img [image create photo backPhoto -file $filename]
backPhoto
% # Just to confirm this is really a TIFF
% exec file $filename
Screenshot from 2015-10-22 23:54:41.png.tiff: TIFF image data, little-endian, direntries=15, height=65, bps=23594, compression=none, PhotometricIntepretation=RGB, orientation=upper-left, width=120

At this point we have the image created and it can be displayed using a Tk label widget. I can only assume your imageName variable doesn't really contain what you think.

Upvotes: 1

Related Questions