GdkPixbuf Constructor

GdkPixbuf::new_from_file_at_size (string filename, int width, int height);

Loads the given image into the pixbuf object and scales it to the given size, respecting the aspect ratio. If an error occurs, an exception of type PhpGtkGErrorException is thrown.

Example 5. Loading and scaling an image file

<?php
//Examle: Loading an image file and scaling it to the given size
try {
    $pixbuf = GdkPixbuf::new_from_file_at_size('test.png', 320, 240);
    echo 'Size: ' . $pixbuf->get_width() . 'x' . $pixbuf->get_height() . "\n";
} catch (Exception $e) {
    //Here we catch errors that could occur
    echo "An error occured:\n";
    echo $e->getMessage() . "\n";
}
?>