_flip_image_resource

Flips an image resource.

Description

(resource) _flip_image_resource( (resource) $img, (bool) $horz, (bool) $vert ); 

Internal use only.

Returns (resource)

(maybe) flipped image resource.

Parameters (3)

0. $img (resource)
Image resource.
1. $horz (bool)
Whether to flip horizontally.
2. $vert (bool)
Whether to flip vertically.

Usage

  1. if ( !function_exists( '_flip_image_resource' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/image-edit.php'; 
  3.  
  4. // Image resource. 
  5. $img = null; 
  6.  
  7. // Whether to flip horizontally. 
  8. $horz = true; 
  9.  
  10. // Whether to flip vertically. 
  11. $vert = true; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = _flip_image_resource($img, $horz, $vert); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/image-edit.php  
  1. function _flip_image_resource($img, $horz, $vert) { 
  2. _deprecated_function( __FUNCTION__, '3.5.0', 'WP_Image_Editor::flip()' ); 
  3. $w = imagesx($img); 
  4. $h = imagesy($img); 
  5. $dst = wp_imagecreatetruecolor($w, $h); 
  6. if ( is_resource($dst) ) { 
  7. $sx = $vert ? ($w - 1) : 0; 
  8. $sy = $horz ? ($h - 1) : 0; 
  9. $sw = $vert ? -$w : $w; 
  10. $sh = $horz ? -$h : $h; 
  11.  
  12. if ( imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh) ) { 
  13. imagedestroy($img); 
  14. $img = $dst; 
  15. return $img;