Offering new extra functionality "scale" and "resize" allow copies
copies made of existing pixbufs at new sizes. Typically a pixbuf will be
an image loaded from disk that would be suitable manipulated prior to
display in a gnocl::image item which has its own buffer resizing
functionality. However, the pixbuf code is pretty fast for scaling
operations in general and so would be useful for simple image
manipulation. Here's how these commands work:
# Create a pixbuf by loading and image from disk.
set pb1 [gnocl::pixBuf load -file ./georgie.png]
# Create copy by simple scale factor, conserves aspect ratio
set pb2 [$pb1 scale 0.25 ]
# Create copy by specifying width scale factors, no conservation of aspect ratio
set pb2 [$pb1 scale -width 0.25 -height 0.25 ]
# Create copy by specific size, does not conserves aspect ratio
set pb3 [$pb1 resize -width 100 -height 150 ]
# Copy with specific width, the height will be calculated based upon image aspect ratio
set pb4 [$pb1 resize -width 100 ]
# Copy with specific height, the width will be calculated based upon image aspect ratio
set pb5 [$pb1 resize -height 150 ]
These commands are pretty straight forward. There may be some function duplication between modules such as wand, but there are probably some speed differences. After all, the Gdk/Gtk libraries are designed for screen rendering and so need to be fast whilst the imageMagick equivalent supports an internal command pipeline for multiple commands and is aimed squarely as disk-based image processing.
# Create a pixbuf by loading and image from disk.
set pb1 [gnocl::pixBuf load -file ./georgie.png]
# Create copy by simple scale factor, conserves aspect ratio
set pb2 [$pb1 scale 0.25 ]
# Create copy by specifying width scale factors, no conservation of aspect ratio
set pb2 [$pb1 scale -width 0.25 -height 0.25 ]
# Create copy by specific size, does not conserves aspect ratio
set pb3 [$pb1 resize -width 100 -height 150 ]
# Copy with specific width, the height will be calculated based upon image aspect ratio
set pb4 [$pb1 resize -width 100 ]
# Copy with specific height, the width will be calculated based upon image aspect ratio
set pb5 [$pb1 resize -height 150 ]
These commands are pretty straight forward. There may be some function duplication between modules such as wand, but there are probably some speed differences. After all, the Gdk/Gtk libraries are designed for screen rendering and so need to be fast whilst the imageMagick equivalent supports an internal command pipeline for multiple commands and is aimed squarely as disk-based image processing.
Comments