image_get_info

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

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

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

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

Drupal only supports GIF, JPG and PNG file formats.

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

FALSE, if the file could not be found or is not an image. Otherwise, a keyed array containing information about the image: 'width' - Width in pixels. 'height' - Height in pixels. 'extension' - Commonly used file extension for the image. 'mime_type' - MIME type ('image/jpeg', 'image/gif', 'image/png'). 'file_size' - File size in bytes.

Связанные темы

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

file_validate_image_resolution in includes/file.inc
If the file is an image verify that its dimensions are within the specified maximum and minimum dimensions. Non-image files will be ignored.
file_validate_is_image in includes/file.inc
Проверяет, распознаётся ли файл функцией image_get_info() как изображение.
hook_prepare in developer/hooks/node.php
Этот хук используется модулями, которые работают с нодами. Он вызывается после загрузки ноды, но перед тем, как нода будет отображена в форме добавления/редактирования.
image_gd_crop in includes/image.gd.inc
Обрезает изображение используя набор инструментов GD.
image_gd_resize in includes/image.gd.inc
Scale an image to the specified size using GD.
image_gd_rotate in includes/image.gd.inc
Поворачивает изображение на заданное число градусов.
image_scale in includes/image.inc
Scales an image to the given width and height while maintaining aspect ratio.
image_scale_and_crop in includes/image.inc
Scales an image to the exact width and height given. Achieves the target aspect ratio by cropping the original image equally on both sides, or equally on the top and bottom. This function is, for example, useful to create uniform sized avatars from...
user_file_download in modules/user/user.module
Implementation of hook_file_download().
user_validate_picture in modules/user/user.module

Код

<?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;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

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