|
 |
imagesx (PHP 3, PHP 4, PHP 5) imagesx -- Get image width Descriptionint imagesx ( resource image )
imagesx() returns the width of the image
identified by image.
Пример 1. Using imagesx()
<?php
$img = imagecreatetruecolor(300, 200);
echo imagesx($img); ?>
|
|
See also imagecreatetruecolor(),
getimagesize() and
imagesy().
imagesx
post at martinl dot net
06-Sep-2005 10:57
<?php
function LoadJpeg($imgname)
{
$im = @imagecreatefromjpeg($imgname); if (!$im) { $im = imagecreatruecolor(150, 30); $bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
}
return $im;
}
$img = LoadJpeg($_GET['bilde']);
$vidde = imagesx($img);
$hoyde = imagesy($img);
imageline($img, 0, 0, $vidde, $hoyde, imagecolorallocate($img, 250, 0, 0));
imageline($img, $vidde, 0, 0, $hoyde, imagecolorallocate($img, 250, 0, 0));
header("Content-type: image/gif");
imagegif($img);
?>
Call this file kryss.php
Go to http://yourdomain.com/kryss.php?bilde=imageurl
Test it here:
http://martinl.net/kryss.php?bilde=http://martinl.net/logo.jpg
Last picture was a .gif...
kris
22-Sep-2004 05:49
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.
anC
26-Aug-2004 11:38
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'.
leonardo AT saochico DOT com
21-Nov-2003 07:24
This function convert image size of Pixel to Centimeter
<?
function px2cm($image, $dpi) {
$img = ImageCreateFromJpeg($image);
$x = ImageSX($img);
$y = ImageSY($img);
$h = $x * 2.54 / $dpi;
$l = $y * 2.54 / $dpi;
$h = number_format($h, 2, ',', ' ');
$l = number_format($l, 2, ',', ' ');
$px2cm[] = $h."cm";
$px2cm[] = $l."cm";
return $px2cm;
}
$image = "C:\\inetpub\\wwwroot\\lab\\trata_img\\l0gik.jpg";
$dpi = 300;
$result = px2cm($image, $dpi);
print ($result[0]." x ".$result[1]);
?>
| |