<th> AutoSharpened <br/><p>WARNING-This feature takes a lot of processing power</p></th>
        <?php 
    foreach ($images as $image) {
        print "<td>";
        ImageMagickSharpen(POSTIE_ROOT . DIRECTORY_SEPARATOR . "test_files" . DIRECTORY_SEPARATOR . $image, $config["REALPHOTOSDIR"] . "Sharp-" . $image);
        print "<img src='" . $config["URLPHOTOSDIR"] . "/Sharp-" . $image . "'>";
        print "</td>\n";
    }
    ?>
    </tr>
    <?php 
}
?>
    <tr>
    <th> Scaled & Rotated</th>
        <?php 
foreach ($images as $image) {
    $result = ResizeImage(POSTIE_ROOT . DIRECTORY_SEPARATOR . "test_files" . DIRECTORY_SEPARATOR . $image, substr($image, -3, 3));
    RotateImages(90, array(array(null, $config["REALPHOTOSDIR"] . $result[0], 'jpg')));
    print "<td>";
    $size = DetermineImageSize($config["REALPHOTOSDIR"] . DIRECTORY_SEPARATOR . $result[0]);
    print "{$size['1']} x {$size['0']}<br\\>\n";
    print "<img src='" . $config["URLPHOTOSDIR"] . $result[0] . "'>";
    print "</td>\n";
}
?>
    </tr>
    </table>
    
</div>
Exemple #2
0
function ResizeImageWithGD($file, $type)
{
    $config = GetConfig();
    $sizeInfo = DetermineImageSize($file);
    $fileName = basename($file);
    $scaledFileName = "";
    $scale = DetermineScale($sizeInfo[0], $sizeInfo[1], $config["MAX_IMAGE_WIDTH"], $config["MAX_IMAGE_HEIGHT"]);
    if ($scale != 1) {
        $sourceImage = NULL;
        switch ($type) {
            case "jpeg":
            case "jpg":
            case "pjpeg":
                $sourceImage = imagecreatefromjpeg($file);
                break;
            case "gif":
                $sourceImage = imagecreatefromgif($file);
                break;
            case "png":
                $sourceImage = imagecreatefrompng($file);
                break;
        }
        if ($sourceImage) {
            $scaledH = round($sizeInfo[1] * $scale);
            $scaledW = round($sizeInfo[0] * $scale);
            $scaledFileName = "thumb." . $fileName;
            $scaledFile = $config["REALPHOTOSDIR"] . $scaledFileName;
            $scaledImage = imagecreatetruecolor($scaledW, $scaledH);
            imagecopyresized($scaledImage, $sourceImage, 0, 0, 0, 0, $scaledW, $scaledH, $sizeInfo[0], $sizeInfo[1]);
            imagejpeg($scaledImage, $scaledFile, $config["JPEGQUALITY"]);
            @exec('chmod 755 ' . escapeshellarg($scaledFile));
            imagedestroy($scaledImage);
            imagedestroy($sourceImage);
        }
    }
    return array($scaledFileName, $fileName);
}