コード例 #1
0
 protected function makeLevelItemArray($level, $fullpath)
 {
     if (!($mimeType = isValidImagePath($fullpath))) {
         return false;
     }
     $filename = basename($fullpath);
     //$reldir = keyVal($level,$this->cmpdirs);
     return ["mimeType_c{$level}" => $mimeType, "file_name_c{$level}" => $filename, "full_path_c{$level}" => $fullpath, "url_c{$level}" => $this->cmpurlroots[$level] . $filename];
 }
コード例 #2
0
ファイル: pklib.php プロジェクト: pkirkaas/PkExtensions
/** If the $filePath is a valid info & can get dimensions, return width/height,
 * else 0/false
 * @param type $filePath
 */
function aspectRatio($filePath) {
  if (!($mimeType = isValidImagePath($filePath))) return false;
  $exif = null;
  try {
    $exif = @exif_read_data($filePath);
  } catch (Exception $e) {
    error_log("Exception Reading EXIF for file [$filePath]: " . $e->getMessage());
    pkdebug("Exception reading EXIF for file [$filePath]:", $e);
  }
  if (($computed = keyVal('COMPUTED', $exif)) && ($width = keyVal('Width', $computed)) && ($height = keyVal('Height', $computed))) {
    return $width / $height;
  }
  #If no exif data, use GD:
  //$gdresource = imagecreatefromstring (file_get_contents($filePath));
  $sz = getimagesize($filePath);
  if (($width = keyVal(0, $sz)) && ($height = keyVal(1, $sz)))
      return $width / $height;
  return false;
}