GdkPixbuf::save

bool save(string filename, string type [, array options]);

Saves the pixbuf into a file of a given type.

Example 10. Save a pixbuf into a file

<?php
//Create a new pixbuf of size 320x240
$pixbuf = new GdkPixbuf(Gdk::COLORSPACE_RGB, false, 8, 320, 240);

//green
$pixbuf->fill(128, 255, 0, 255);

//save it as a png file
$pixbuf->save('green.png', 'png');
?>

The optional third options can be a list of keys and values that depend on the output format. E.g., jpg has a quality parameter that defines the jpg quality from 0 to 100.

Example 11. Save a pixbuf into a jpg

<?php
//Create a new pixbuf of size 320x240
$pixbuf = new GdkPixbuf(Gdk::COLORSPACE_RGB, false, 8, 320, 240);

//green
$pixbuf->fill(128, 255, 0, 255);

//save it as a png file
$pixbuf->save('green.jpg', 'jpg', array('quality' => 85));
?>