image_get_info

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

includes/image.inc, строка 82

Версии
5 – 6
image_get_info($file)

Возвращает информацию о формате изображения.

Возвращаемое значение

Массив содержит информацию (в пикселях) о ширине ('width') изображения, его высоте 'hieght', его расширении в соответствии с 'mime_type'. Так же содержит MIME type изображения ('image/jpeg', 'image/gif', и т.д.) и 'file_size': физический размер файла изображения (в байтах)

▾ 9 функции вызывают image_get_info()

hook_prepare in developer/hooks/node.php
Этот хук используется модулями, которые работают с нодами. Он вызывается после загрузки ноды, но перед тем, как нода будет отображена в форме добавления/редактирования.
image_gd_crop in includes/image.inc
Crop an image using the GD toolkit.
image_gd_resize in includes/image.inc
Scale an image to the specified size using GD.
image_gd_rotate in includes/image.inc
Rotate an image the given number of degrees.
image_scale in includes/image.inc
Scales an image to the given width and height while maintaining aspect ratio.
system_theme_settings in modules/system/system.module
Menu callback; display theme configuration for entire site and individual themes.
user_file_download in modules/user/user.module
Implementation of hook_file_download().
user_validate_picture in modules/user/user.module
_upload_image in modules/upload/upload.module
Check an upload, if it is an image, make sure it fits within the maximum dimensions allowed.

Код

<?php
function image_get_info($file) {
  if (!is_file($file)) {
    return FALSE;
  }

  $details = FALSE;
  $data = @getimagesize($file);
  $file_size = @filesize($file);

  if (isset($data) && is_array($data)) {
    $extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png');
    $extension = array_key_exists($data[2], $extensions) ?  $extensions[$data[2]] : '';
    $details = array('width'     => $data[0],
                     'height'    => $data[1],
                     'extension' => $extension,
                     'file_size' => $file_size,
                     'mime_type' => $data['mime']);
  }

  return $details;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему