Exemplo n.º 1
0
function displayTestWatermarkImage(array $test_data_set)
{
    foreach ($test_data_set as $image_ext => $items) {
        echo '<h3><a href="' . $items['source_image_path'] . '">' . $image_ext . '</a><img src="' . $items['source_image_path'] . '" alt="" class="thumbnail"></h3>' . "\n";
        $Image = new \Rundiz\Image\Drivers\Gd($items['source_image_path']);
        $main_save_file_name = '../processed-images/rundiz-gd-image-watermarkImage-testpage-source-' . strtolower($image_ext);
        foreach ($items['watermark_exts'] as $wm_ext) {
            $wmext_save_file_name = $main_save_file_name . '-watermark-' . $wm_ext;
            $watermark_image_path = '../source-images/watermark.' . $wm_ext;
            echo '<h4>watermark from <a href="' . $watermark_image_path . '">' . $wm_ext . '</a><img src="' . $watermark_image_path . '" alt="" class="thumbnail"></h4>' . "\n";
            foreach ($items['watermark_positions'] as $wm_pos) {
                $save_file_name = $wmext_save_file_name . '-position-' . $wm_pos[0] . ',' . $wm_pos[1];
                echo 'position ' . $wm_pos[0] . ', ' . $wm_pos[1] . '<br>';
                foreach ($items['watermark_exts'] as $save_ext) {
                    $Image->watermarkImage($watermark_image_path, $wm_pos[0], $wm_pos[1]);
                    $Image->save($save_file_name . '.' . $save_ext);
                    $Image->clear();
                    echo '<a href="' . $save_file_name . '.' . $save_ext . '">save as ' . $save_ext . '</a><img src="' . $save_file_name . '.' . $save_ext . '" alt="" class="thumbnail"> ';
                }
                echo '<br>' . "\n";
                unset($save_file_name);
            }
            unset($watermark_image_path, $wmext_save_file_name, $wm_pos);
        }
        unset($Image, $main_save_file_name);
    }
}
Exemplo n.º 2
0
function displayTestRotate(array $test_data_set)
{
    $test_rotate = array(90, 180, 270, 'hor', 'vrt', 'horvrt');
    echo '<h2>Rotate/flip images</h2>' . "\n";
    if (is_array($test_data_set)) {
        foreach ($test_data_set as $img_type_name => $item) {
            echo '<h3>' . $img_type_name . '</h3>' . "\n";
            if (is_array($item) && array_key_exists('source_image_path', $item)) {
                echo 'Source image: <a href="' . $item['source_image_path'] . '"><img src="' . $item['source_image_path'] . '" alt="" class="thumbnail"></a><br>' . "\n";
                $Image = new \Rundiz\Image\Drivers\Gd($item['source_image_path']);
                $source_image_exp = explode('.', $item['source_image_path']);
                $file_ext = '.';
                if (is_array($source_image_exp)) {
                    $file_ext .= $source_image_exp[count($source_image_exp) - 1];
                }
                unset($source_image_exp);
                foreach ($test_rotate as $rotate) {
                    $file_name = '../processed-images/rundiz-gd-image-rotate-' . str_replace(' ', '-', strtolower($img_type_name)) . '-rotate' . $rotate;
                    echo 'Rotate at <a href="' . $file_name . $file_ext . '">' . $rotate . '</a><img src="' . $file_name . $file_ext . '" alt="" class="thumbnail"><br>' . "\n";
                    $Image->rotate($rotate);
                    $save_result = $Image->save($file_name . $file_ext);
                    if ($save_result != true) {
                        echo ' &nbsp; &nbsp; Error: ' . $Image->status_msg . '<br>' . "\n";
                    }
                    unset($file_name, $save_result);
                    $Image->clear();
                }
                // endforeach;
                $Image->clear();
                unset($file_ext, $Image, $rotate);
            }
            echo "\n\n";
        }
        // endforeach;
    }
    echo "\n\n";
}
Exemplo n.º 3
0
//
$rotate = 270;
$file_name = '../processed-images/rundiz-gd-image-rotate-testpage-' . $rotate . 'degree.png';
$Image->rotate($rotate);
$Image->save($file_name);
$Image->clear();
echo '<a href="' . $file_name . '">' . $rotate . ' degree</a><img src="' . $file_name . '" alt="" class="thumbnail"> ';
//
unset($Image);
// ------------------------------------------------------------------------------------------------------
?>
 
        <h2>GIF</h2>
        <?php 
echo '<a href="' . $source_image_gif . '">source image</a><img src="' . $source_image_gif . '" alt="" class="thumbnail"><br>' . "\n";
$Image = new \Rundiz\Image\Drivers\Gd($source_image_gif);
$rotate = 90;
$file_name = '../processed-images/rundiz-gd-image-rotate-testpage-' . $rotate . 'degree.gif';
$Image->rotate($rotate);
$Image->save($file_name);
$Image->clear();
echo '<a href="' . $file_name . '">' . $rotate . ' degree</a><img src="' . $file_name . '" alt="" class="thumbnail"> ';
//
$rotate = 180;
$file_name = '../processed-images/rundiz-gd-image-rotate-testpage-' . $rotate . 'degree.gif';
$Image->rotate($rotate);
$Image->save($file_name);
$Image->clear();
echo '<a href="' . $file_name . '">' . $rotate . ' degree</a><img src="' . $file_name . '" alt="" class="thumbnail"> ';
//
$rotate = 270;
Exemplo n.º 4
0
$file_name = $base_save_file_name . '-sourcepng.' . $file_ext;
$Image->resizeNoRatio($resize_w, $resize_h);
$Image->rotate($rotate);
$Image->crop($crop_width, $crop_height);
$Image->save($file_name);
$Image->clear();
echo '<a href="' . $file_name . '">' . $file_ext . '</a><img src="' . $file_name . '" alt="" class="thumbnail"> ';
unset($file_name, $Image);
// -------------------------------------------------------------------------------------------------------------------
?>
 
        <h2>GIF</h2>
        <?php 
echo '<a href="' . $source_image_gif . '">source image</a><img src="' . $source_image_gif . '" alt="" class="thumbnail"><br>' . "\n";
echo 'Save as: ' . "\n";
$Image = new \Rundiz\Image\Drivers\Gd($source_image_gif);
$file_ext = 'jpg';
$file_name = $base_save_file_name . '-sourcegif.' . $file_ext;
$Image->resizeNoRatio($resize_w, $resize_h);
$Image->rotate($rotate);
$Image->crop($crop_width, $crop_height);
$Image->save($file_name);
$Image->clear();
echo '<a href="' . $file_name . '">' . $file_ext . '</a><img src="' . $file_name . '" alt="" class="thumbnail"> ';
$file_ext = 'png';
$file_name = $base_save_file_name . '-sourcegif.' . $file_ext;
$Image->resizeNoRatio($resize_w, $resize_h);
$Image->rotate($rotate);
$Image->crop($crop_width, $crop_height);
$Image->save($file_name);
$Image->clear();
Exemplo n.º 5
0
    if ($degree != 'hor' && $degree != 'vrt' && $degree != 'horvrt') {
        $degree = 0;
    }
}
if (is_numeric($start_x)) {
    $start_x = intval($start_x);
}
if (is_numeric($start_y)) {
    $start_y = intval($start_y);
}
if (!is_numeric($fontsize)) {
    $fontsize = 15;
} else {
    $fontsize = intval($fontsize);
}
$Image = new \Rundiz\Image\Drivers\Gd($source_image_file);
switch ($act) {
    case 'watermarktext':
        $Image->watermarkText('Rundiz watermark สั้น ญู ให้ ทดสอบสระ.', '../source-images/cschatthai.ttf', $start_x, $start_y, $fontsize);
        break;
    case 'crop':
        $Image->crop($width, $height);
        break;
    case 'rotate':
        $Image->rotate($degree);
        break;
    case 'resizenoratio':
        $Image->resizeNoRatio($width, $height);
        break;
    case 'resize':
    default:
Exemplo n.º 6
0
function displayTestResizeRatio(array $test_data_set)
{
    foreach ($test_data_set as $main_ext => $items) {
        echo '<h2><a href="' . $items['source_image_path'] . '">' . $main_ext . '</a><img src="' . $items['source_image_path'] . '" alt="" class="thumbnail"></h2>' . "\n";
        $Image = new \Rundiz\Image\Drivers\Gd($items['source_image_path']);
        $master_dim = 'auto';
        echo '<h3>Not allow resize larger, master dimension ' . $master_dim . '</h3>' . "\n";
        $base_save_file_name = '../processed-images/rundiz-gd-image-resizeratio-testpage';
        $base_save_file_name2 = $base_save_file_name . '-nolarger-masterdim-' . $master_dim;
        $Image->master_dim = $master_dim;
        echo 'Saved as: ';
        foreach ($items['resize_sizes'] as $sizes) {
            $base_save_file_name3 = $base_save_file_name2 . '-resize-' . $sizes[0] . 'x' . $sizes[1] . '.' . $items['save_as'];
            $Image->resize($sizes[0], $sizes[1]);
            $Image->save($base_save_file_name3);
            $Image->clear();
            list($saved_w, $saved_h) = getimagesize($base_save_file_name3);
            if ($saved_w != $sizes[0] || $saved_h != $sizes[1]) {
                echo $sizes[0] . 'x' . $sizes[1] . ' =&gt; ';
            }
            echo '<a href="' . $base_save_file_name3 . '">' . $saved_w . 'x' . $saved_h . '</a><img src="' . $base_save_file_name3 . '" alt="" class="thumbnail"> ';
            echo ' &nbsp; &nbsp;';
            unset($base_save_file_name3, $saved_h, $saved_w);
        }
        unset($base_save_file_name, $base_save_file_name2, $sizes);
        echo '<br>';
        // allow resize larger
        $Image->allow_resize_larger = true;
        echo '<h3>Allow resize larger, master dimension ' . $master_dim . '</h3>' . "\n";
        $base_save_file_name = '../processed-images/rundiz-gd-image-resizeratio-testpage';
        $base_save_file_name2 = $base_save_file_name . '-allowlarger-masterdim-' . $master_dim;
        $Image->master_dim = $master_dim;
        echo 'Saved as: ';
        foreach ($items['resize_sizes'] as $sizes) {
            $base_save_file_name3 = $base_save_file_name2 . '-resize-' . $sizes[0] . 'x' . $sizes[1] . '.' . $items['save_as'];
            $Image->resize($sizes[0], $sizes[1]);
            $Image->save($base_save_file_name3);
            $Image->clear();
            list($saved_w, $saved_h) = getimagesize($base_save_file_name3);
            if ($saved_w != $sizes[0] || $saved_h != $sizes[1]) {
                echo $sizes[0] . 'x' . $sizes[1] . ' =&gt; ';
            }
            echo '<a href="' . $base_save_file_name3 . '">' . $saved_w . 'x' . $saved_h . '</a><img src="' . $base_save_file_name3 . '" alt="" class="thumbnail"> ';
            echo ' &nbsp; &nbsp;';
            unset($base_save_file_name3, $saved_h, $saved_w);
        }
        unset($base_save_file_name, $base_save_file_name2, $sizes);
        echo '<br>';
        // not allow resize larger, master dim = height
        $master_dim = 'height';
        $Image->allow_resize_larger = false;
        echo '<h3>Not allow resize larger, master dimension ' . $master_dim . '</h3>' . "\n";
        $base_save_file_name = '../processed-images/rundiz-gd-image-resizeratio-testpage';
        $base_save_file_name2 = $base_save_file_name . '-nolarger-masterdim-' . $master_dim;
        $Image->master_dim = $master_dim;
        echo 'Saved as: ';
        foreach ($items['resize_sizes'] as $sizes) {
            $base_save_file_name3 = $base_save_file_name2 . '-resize-' . $sizes[0] . 'x' . $sizes[1] . '.' . $items['save_as'];
            $Image->resize($sizes[0], $sizes[1]);
            $Image->save($base_save_file_name3);
            $Image->clear();
            list($saved_w, $saved_h) = getimagesize($base_save_file_name3);
            if ($saved_w != $sizes[0] || $saved_h != $sizes[1]) {
                echo $sizes[0] . 'x' . $sizes[1] . ' =&gt; ';
            }
            echo '<a href="' . $base_save_file_name3 . '">' . $saved_w . 'x' . $saved_h . '</a><img src="' . $base_save_file_name3 . '" alt="" class="thumbnail"> ';
            echo ' &nbsp; &nbsp;';
            unset($base_save_file_name3, $saved_h, $saved_w);
        }
        unset($base_save_file_name, $base_save_file_name2, $sizes);
        echo '<br>';
        unset($Image, $master_dim);
    }
    unset($items, $main_ext);
}