FPDF image size -


i'm using fpdf php add image pdf , want put automatically size of image find function

    function fctaffichimage($img_src, $w_max, $h_max) {   if (file_exists($img_src)) {    $img_size = getimagesize($img_src);    $w_src = $img_size[0]; // largeur source    $h_src = $img_size[1]; // hauteur source    if(!$w_max) { $w_max = 0; }    if(!$h_max) { $h_max = 0; }    $w_test = round($w_src * ($h_max / $h_src));    $h_test = round($h_src * ($w_max / $w_src));    if($w_src<$w_max && $h_src<$h_max) {       $w = $w_src;       $h = $h_src;    } elseif($w_max==0 && $h_max==0) {       $w = $w_src;       $h = $h_src;    } elseif($w_max==0) {       $w = $w_test;       $h = $h_max;    } elseif($h_max==0) {       $w = $w_max;       $h = $h_test;      }     elseif($h_test > $h_max) {       $w = $w_test;       $h = $h_max;    } else {       $w = $w_max;       $h = $h_test;    }  }     } 

but when

// requĂȘte $tab1 = $_get['tab1']; $id = $_get['id']; $table = $_get['table']; $ree = "select title,title2 $tab1 $table = $id order 1";  $sql2 = mysql_query($ree);    // on affiche les deux images avec la fontion fctaffichimage   while ($roww = mysql_fetch_assoc($sql2))         {              $nomm = $roww["title"];             $url = "/var/www/images/".$nomm ;             fctaffichimage($url,100,100 );             $pdf->cell(40,6,'',0,0,'c',$pdf->image($img_src,85,55));          } 

it didn't work try change position of $url = "/var/www/images/".$nomm ; fctaffichimage($url,100,100 ); didn't work too.

i see hope you. put @ bottom of function fctaffichimage next code:

$img1 = imagecreatefrompng($img_src); $img2 = imagecreatetruecolor($w, $h); imagecopyresampled($img2, $img1, 0, 0, 0, 0, $w, $h, $w_src, $w_src); imagepng($img2, $img_src); 

here put png image, can generalize it, depends of need. it's running in enviroment php 5.3 (but there's new imagescale function in php 5.5).


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -