DJ Mike's Tutorials: PHP

Imagemagick Functions


^

Imagick::getImageSize

Description:
int Imagick::getImageSize ( void )

Returns the image length in bytes
Return Values
Returns an integer containing the current image size..

Example


Click Image

<form>
<input name="in" type="image" src="opossum.jpg" cursor />
<br />
<?
if ( $_GET[in_x]  )
{
$image = new imagick"opossum.jpg" ); 
echo 
"<table border=\"1\"><tr>";
echo 
"<td align=\"right\"><b>X</b>= $_GET[in_x]</td><td><b>Y</b>= $_GET[in_y] </td></tr>";

# Make ImagePixelColor object from point clicked on.
$point $image->getImagePixelColor$_GET[in_x], $_GET[in_y]);

# get color count
$colorcount $point->getColorCount();
echo 
"<tr><td align=\"right\"><b>Color Count at ($_GET[in_x],$_GET[in_y]):</b></td>
<td>
$color_string</td></tr>";

# Get hue, saturation and luminosity
$hsl $point->getHSL();

echo 
"<tr><td align=\"right\"><b>Hue at ($_GET[in_x],$_GET[in_y]):</b></td>
<td>
$hsl[hue]</td></tr>";

echo 
"<tr><td align=\"right\"><b>Saturation at ($_GET[in_x],$_GET[in_y]):</b></td>
<td>
$hsl[saturation]</td></tr>";

echo 
"<tr><td align=\"right\"><b>Luminosity at ($_GET[in_x],$_GET[in_y]):</b></td>
<td>
$hsl[luminosity]</td></tr>";

# Get image width
$width $image->getimagewidth();
echo 
"<tr><td align=\"right\"><b>Width:</b></td><td>$width</td></tr>";

# Get image height
$height $image->getimageheight();
echo 
"<tr><td align=\"right\"><b>Height:</b></td><td>$height</td></tr>";

# Get image bytes
$bytes $image->getImageSize();
echo 
"<tr><td align=\"right\"><b>Bytes:</b></td><td>$bytes</td></tr>";

# Set format
$image->setformat("jpeg");
# get format
$format $image->getformat();
echo 
"<tr><td align=\"right\"><b>Format:</b></td><td>$format</td></tr>";

# Get number of colors
$color_number $image->getImageColors();
echo 
"<tr><td align=\"right\"><b>Number Of Colors:</b></td><td>$color_number</td></tr>";

#Get resolution
$resolution $image->getImageResolution();
echo 
"<tr><td align=\"right\"><b>Resolution:</b></td>
<td>x=
$resolution[x], y=$resolution[y]</td></tr>";

# Get colorspace
$colorspace $image->getImageColorspace();
echo 
"<tr><td align=\"right\"><b>Colorspace:</b></td>
<td>
$colorspace</td></tr>";
echo 
"</table>";
}
else { echo 
"Click Image"; }
?>
</form>



^

Was this webpage useful to you? You can support this website by donating.


Created by DJ Mike from Santa Barbara

DJ Mike


<a href="http://www.statcounter.com/" target="_blank"> <img src="http://c5.statcounter.com/counter.php?sc_project=1321035&java=0&security=da2193dc" alt="counter free hit invisible" border="0" /></a>