Warning: file_put_contents(): Only -1 of 76 bytes written, possibly out of free disk space in /var/www/html/index.php on line 3

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/index.php:3) in /var/www/html/cache.php on line 23

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/index.php:3) in /var/www/html/cache.php on line 24

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/index.php:3) in /var/www/html/cache.php on line 25
Prev   GdkPixbuf Constructor Next GdkPixbuf::new_from_file_at_size (string filename , int width height ); Loads the given image into pixbuf object and scales it to given size, respecting aspect rat...
Forum und email

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 3. 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";
}
?>