Created
          July 31, 2014 10:39 
        
      - 
      
- 
        Save CodeBrauer/f7412fc578f41cb66a05 to your computer and use it in GitHub Desktop. 
    Converts px to cm (with DPI) and variable precision
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| function get_cm_by_px($px, $dpi = 300, $precision = 2) { | |
| $comma = ','; // if US use '.' | |
| return number_format(2.54 * $pic->exif->size->height / $dpi , $precision, $comma,'') ; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Example:
1000px Photo = 8,47cm (if printed with 300DPI)
Result: (test with all PHP 4.3.0 - 5.6.0 versions) -> http://3v4l.org/Z1LmO