/** * Mirrors the image horizontally. * Uses an affine transformation matrix to mirror the image. * * 123 -> 321 * * @return void */ function mirror() { $outputSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, $this->img_x, $this->img_y); $outputContext = cairo_create($outputSurface); // xx, yx, xy, yy, x0, y0 $matrix = cairo_matrix_create(-1, 0, 0, 1, $this->img_x, 0); cairo_set_matrix($outputContext, $matrix); cairo_set_source_surface($outputContext, $this->surface, 0, 0); cairo_paint($outputContext); cairo_destroy($outputContext); cairo_surface_destroy($this->surface); $this->surface = $outputSurface; }
/** * 画像保存 * * CairoのPNG画像を保存します。 * * @param string $filePath 保存画像のファイルパス * @param string $format 画像ファイルのフォーマット * * @return void */ public function save($filePath, $format = 'png') { unset($format); cairo_surface_write_to_png($this->surface, $filePath); $isSaved = file_exists($filePath); $log = array('isSaved' => $isSaved, 'surface' => $this->surface, 'is_res' => is_resource($this->surface), 'file path' => $filePath, 'file_exists' => file_exists($filePath), 'file size' => filesize($filePath)); $this->_log->log('cairo_surface_write_to_png', $log); cairo_surface_destroy($this->surface); }