Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shrink an image

Status
Not open for further replies.

zby

Programmer
Oct 31, 2003
22
0
0
CZ
Hallo,
let's say that I have an image file of size of 1000x2000px
I use
>> set img [image create photo -format "tiff" -file "test.tif"] <<

Now I need to shrink it into a 640x480 and idsplay it like
>> pack [lable .one.l -image $img] <<

Can you give me a clue on hoe to shrink it?
PS. A newbie.
Thank you
 
I know I've done this but not for a while. If I recall correctly, you do that during the "image create" step. You can specify -width and -height options (in pixels).

Bob Rashkin
rrashkin@csc.com
 
Thanks, however this:
>> set img [image create photo -file "test.tif" -width $f_one_width -height $f_one_height] <<

is what you probably mean and it doesn't satisfy me. This command doesn't shrink. It creates the xy target border of the image area to display. Once I apply this construction I see just a portion of the image within the -width $f_one_width -height $f_one_height area.

Doesn't occure to you that it could be done through:
>> $img copy .... << ?
zby
 
There is a -shrink option under the image copy commands but I don't think it does what you want, really:
Specifies that the size of the destination image should be reduced, if necessary, so that the region being copied into is at the bottom-right corner of the image. This option will not affect the width or height of the image if the user has specified a non-zero value for the -width or -height configuration option, respectively.


Bob Rashkin
rrashkin@csc.com
 
Thanks for a reply.
I tested the -shrink option, but the whole application crashed for the "unauthorized access to memory" attempt. Weird, but true. I may do something wrong then.
However I tested:
>> package require img::tiff
>> ....... some code .......
>> set source [image create photo -file "test.tif"]
>> set img [image create photo]
>> $img copy $source -subsample 4 4
>> pack [label .one.l -image $img]

This construction cause to zoom out (staticly) which I want! However, to accomplish the whole project I want to be able to zoom in/outwith a button press, leaf through tiff pages if multitiff etc.
I'm using tkimg1.3rc2 package, but yet I did not find out how to process the multitiffs.
Also the:
>> $img copy $source -subsample 4 4
expression seems to me a waste of memory while another image ($source) must be opened to perform the copy. Unless I am mistaken.
I need to find out a function that initialy fits the image into the current window/frame and dynamicly changes its size according to the instant window/frame size.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top