imagesx

(PHP 4, PHP 5, PHP 7)

imagesxПолучение ширины изображения

Описание

int imagesx ( resource $image )

Возвращает ширину заданного изображения image.

Список параметров

image

Ресурс изображения, полученный одной из функций создания изображений, например, такой как imagecreatetruecolor().

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

Возвращает ширину изображения image или FALSE в случае ошибки.

Примеры

Пример #1 Пример использования imagesx()

<?php

// создание изображения 300*200 
$img imagecreatetruecolor(300200);

echo 
imagesx($img); // 300

?>

Смотрите также

  • imagecreatetruecolor() - Создание нового полноцветного изображения
  • getimagesize() - Получение размера изображения
  • imagesy() - Получение высоты изображения

Коментарии

This function convert image size of Pixel to Centimeter

<?
#$imagem - source of image
#$dpi - resolution to convert E.g.: 72dpi or 300dpi

function px2cm($image$dpi) {
   
#Create a new image from file or URL
   
$img ImageCreateFromJpeg($image);

   
#Get image width / height
   
$x ImageSX($img);
   
$y ImageSY($img);
   
   
#Convert to centimeter
   
$h $x 2.54 $dpi;
   
$l $y 2.54 $dpi;
   
   
#Format a number with grouped thousands
   
$h number_format($h2','' ');
   
$l number_format($l2','' ');
   
   
#add size unit
   
$px2cm[] = $h."cm";
   
$px2cm[] = $l."cm";
   
   
#return array w values
    #$px2cm[0] = X
    #$px2cm[1] = Y   
   
return $px2cm;
}

$image "C:\\inetpub\\wwwroot\\lab\\trata_img\\l0gik.jpg";
$dpi 300;

$result px2cm($image$dpi);

print (
$result[0]." x ".$result[1]);
?>
2003-11-21 09:24:32
http://php5.kiev.ua/manual/ru/function.imagesx.html
Автор:
You can't convert pixels into centimeters or something else, atleast without knowing the resolution and the size of your screen and the viewrange of it. For example: The pixels on monitor that's resolution is 1024*768 and size is 17' the size of a pixel is smaller than on the monitor that's resolution is 1024*768 too but size is 21'.
2004-08-27 02:38:55
http://php5.kiev.ua/manual/ru/function.imagesx.html
Автор:
You can in fact convert pixels to CM or to whatever measurement you want if you know the DPI and current resolution of the image.  This will of course give you the real life print size of the image and not the actual on screen size of the image. 

This function seems to have been created for such a purpose.  It is for this reason the creator of the function passes the DPI and resolution to his function.
2004-09-22 20:49:59
http://php5.kiev.ua/manual/ru/function.imagesx.html

    Поддержать сайт на родительском проекте КГБ