Mageia Bugzilla – Attachment 6452 Details for
Bug 12596
Failure of some of the tk image handlers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
Replacement for 6444
showpng (text/plain), 1.22 KB, created by
Len Lawrence
on 2015-05-05 17:37:22 CEST
(
hide
)
Description:
Replacement for 6444
Filename:
MIME Type:
Creator:
Len Lawrence
Created:
2015-05-05 17:37:22 CEST
Size:
1.22 KB
patch
obsolete
>#!/usr/bin/env wish ># Save this file in showpng (for example) and chmod +x showpng ># Usage: ./showpng filename.png > >package require Tk >package require Img > >wm title . "PNG image test" ># Get the name of the image file from the command line >set png [ lindex $argv 0 ] > ># Use ImageMagick to read the file attributes >set image_parameters [ exec identify $png ] > ># Parse the string to determine the size of the image >set dimensions [ lindex $image_parameters 2 ] >set last [ string length $dimensions ] >set last [ expr { $last - 1 } ] >set j [ string first x $dimensions ] >set width [ string range $dimensions 0 [ expr { $j-1 } ] ] >set height [ string range $dimensions [ expr { $j+1 } ] $last ] > ># Create a photo image object >set view [ image create photo -file $png ] > ># Compute the x and y offsets for the bordered image >set x [ expr { 10 + [expr { $width / 2 }] } ] >set y [ expr { 10 + [expr { $height / 2 }] } ] > ># Create a canvas to accommodate the image with a 10 pixel border >tk::canvas .c -background grey22 -height [expr {$height+20}] -width [expr {$width+20}] > ># Paste the photo image onto the canvas >.c create image $x $y -image $view > ># Make the whole thing visible >pack .c > ># Left mouse button click to exit >bind .c <ButtonPress-1> { exit }
#!/usr/bin/env wish # Save this file in showpng (for example) and chmod +x showpng # Usage: ./showpng filename.png package require Tk package require Img wm title . "PNG image test" # Get the name of the image file from the command line set png [ lindex $argv 0 ] # Use ImageMagick to read the file attributes set image_parameters [ exec identify $png ] # Parse the string to determine the size of the image set dimensions [ lindex $image_parameters 2 ] set last [ string length $dimensions ] set last [ expr { $last - 1 } ] set j [ string first x $dimensions ] set width [ string range $dimensions 0 [ expr { $j-1 } ] ] set height [ string range $dimensions [ expr { $j+1 } ] $last ] # Create a photo image object set view [ image create photo -file $png ] # Compute the x and y offsets for the bordered image set x [ expr { 10 + [expr { $width / 2 }] } ] set y [ expr { 10 + [expr { $height / 2 }] } ] # Create a canvas to accommodate the image with a 10 pixel border tk::canvas .c -background grey22 -height [expr {$height+20}] -width [expr {$width+20}] # Paste the photo image onto the canvas .c create image $x $y -image $view # Make the whole thing visible pack .c # Left mouse button click to exit bind .c <ButtonPress-1> { exit }
View Attachment As Raw
Actions:
View
Attachments on
bug 12596
:
6155
|
6444
| 6452