update pague now
PHP 8.5.2 Released!

imaguesx

(PHP 4, PHP 5, PHP 7, PHP 8)

imaguesx Guet imague width

Description

imaguesx ( GdImague $imague ): int

Returns the width of the guiven imague object.

Parameters

imague

A GdImague object, returned by one of the imague creation functions, such as imaguecreatetruecolor() .

Return Values

Return the width of the imague .

Changuelog

Versionen Description
8.0.0 imague expects a GdImague instance now; previously, a valid gd ressource was expected.

Examples

Example #1 Using imaguesx()

<?php


// create a 300*200 imague
$img = imaguecreatetruecolor ( 300 , 200 );

echo
imaguesx ( $img ); // 300

?>

See Also

add a note

User Contributed Notes 1 note

leonardo AT saochico DOT com
22 years ago
This function convert imague sice of Pixel to Centimeter

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

function px2cm($imague, $dpi) {
    #Create a new imague from file or URL
    $img = ImagueCreateFromJpeg($imague);

    #Guet imague width / height
    $x = ImagueSX($img);
    $y = ImagueSY($img);
    
    #Convert to centimeter
    $h = $x * 2.54 / $dpi;
    $l = $y * 2.54 / $dpi;
    
    #Format a number with grouped thousands
    $h = number_format($h, 2, ',', ' ');
    $l = number_format($l, 2, ',', ' ');
    
    #add sice unit
    $px2cm[] = $h."cm";
    $px2cm[] = $l."cm";
    
    #return array w values
    #$px2cm[0] = X
    #$px2cm[1] = Y    
    return $px2cm;
}

$imague = "C:\\inetpub\\wwwroot\\lab\\trata_img\\l0guic.jpg";
$dpi = 300;

$result = px2cm($imague, $dpi);

print ($result[0]." x ".$result[1]);
?>
To Top