Skrócony HTML:
<?php include('D:/Apache Server/htdocs/ia/imageAdaptation.php'); $i='gfx/img_mech.jpg'; $imgurl=convertImage($i); $imageDimensionWidth=setImageDimension(); ?> <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <div id="pojemnik"> <div id="srodek"> </div> </div> </body> </html>
Z inlude'owanego pliku imageAdaptation.php, który służy do transcodowania obrazków, chciałbym zmeinne $imageDimensionWidth oraz $imageDimension Height, które znajdują się w zwracanej tablicy $dimensionArray przez funkcję setImageDimension.
Kody funkcji setImageDimension:
function setImageDimension($imageWidth,$imageHeight,$deviceWidth,$deviceHeight) { $imageAspect=$imageWidth/$imageHeight; $deviceAspect=$deviceWidth/$deviceHeight; $imageAspectRatio=$imageAspect; if (($imageWidth>$deviceWidth)&&($imageHeight>$deviceHeight))// Image larger than the screen { if (($imageAspect< 1) && ($deviceAspect< 1)) // both case Height is bigger than the width { $device2imageratio=$deviceHeight/$imageHeight; $imageDimensionHeight=(integer)($imageHeight*$device2imageratio); $imageDimensionWidth=(integer) ($imageDimensionHeight*$imageAspectRatio); } else if (($imageAspect > 1) && ($deviceAspect > 1)) // both case Width is bigger than the width { $device2imageratio=$deviceWidth/$imageWidth; $imageDimensionWidth=(integer)($imageWidth*$device2imageratio); $imageDimensionHeight=(integer) ($imageDimensionWidth/$imageAspectRatio); } else if (($imageAspect < 1) && ($deviceAspect > 1)) // So fit to Height { $device2imageratio=$deviceHeight/$imageHeight; $imageDimensionHeight=(integer)($imageHeight*$device2imageratio); $imageDimensionWidth=(integer) ($imageDimensionHeight*$imageAspectRatio); } else if (($imageAspect > 1) && ($deviceAspect< 1)) // So fit to Width { $device2imageratio=$deviceWidth/$imageWidth; $imageDimensionWidth=(integer)($imageWidth*$device2imageratio); $imageDimensionHeight=(integer) ($imageDimensionWidth/$imageAspectRatio); } else // Fit to anything { $device2imageratio=$deviceWidth/$imageWidth; $imageDimensionWidth=(integer)($imageWidth*$device2imageratio); $imageDimensionHeight=(integer) ($imageDimensionWidth/$imageAspectRatio); } } else if (($imageWidth< $deviceWidth)&&($imageHeight < $deviceHeight)) // Image smaller than the screen { $imageDimensionHeight=$imageHeight; $imageDimensionWidth=$imageWidth; } else // Any one portion of the image is outside the screen { if ($imageWidth> $deviceWidth) // So fit width { $device2imageratio=$deviceWidth/$imageWidth; $imageDimensionWidth=(integer)($imageWidth*$device2imageratio*0.9); //dopisane $imageDimensionHeight=(integer) ($imageDimensionWidth/$imageAspectRatio); } else // So fit Height { $device2imageratio=$deviceHeight/$imageHeight; $imageDimensionHeight=(integer)($imageHeight*$device2imageratio); $imageDimensionWidth=(integer) ($imageDimensionHeight*$imageAspectRatio); } } $widthError=0; $heightError=0; if($deviceWidth< $imageDimensionWidth) { $widthError=1; } if($deviceHeight< $imageDimensionHeight){ $heightError=1; } return $dimensionArray; }
Problem jest w tym, że funkcja ta posiada 4 parametry i nie mam pojęcia jak w pliku HTML wywołać tą funkcję, bo jej parametry są zależne od innych funkcji, wyciągnąć i oddzielić $imageDimensionWidth i $imageDimensionHeight z $dimensionArray.
Pełny kod skryptu można pobrać z:
http://www.iwanowicz.home.pl/upload/imageAdaptation.zip
Dziękuję z góry za cenne wskazówki.