Hi i have a long script named images.php that handles the image manipulation and the following script to handle multiple images at once

    <?php

    // load the image manipulation class
    require '../../image.php';

    // create a new instance of the class
    $image = new Zebra_Image();

$directory = 'jocuri';
if ($handle = opendir($directory.'/')) {
    $cat=array_diff(scandir($directory), array('.', '..', 'index.php'));
    //shuffle($cat);
        foreach($cat as $key => $game) {
        if ($cat!='.'&&$cat!='..'&&$cat!='index.php') {
                // indicate a target image
                // note that there's no extra property to set in order to specify the target 
                // image's type -simply by writing '.jpg' as extension will instruct the script 
                // to create a 'jpg' file
                echo $image->target_path = $directory.'/'.$game.'/thumb.jpg';   
            }
        }
    }


    // indicate a source image (a GIF, PNG or JPEG file)
    //$image->source_path = 'path/to/image.png';


    // since in this example we're going to have a jpeg file, let's set the output 
    // image's quality
    $image->jpeg_quality = 100;

    // some additional properties that can be set
    // read about them in the documentation
    $image->preserve_aspect_ratio = true;
    $image->enlarge_smaller_images = true;
    $image->preserve_time = true;

    // resize the image to exactly 100x100 pixels by using the "crop from center" method
    // (read more in the overview section or in the documentation)
    //  and if there is an error, check what the error is about
    if (!$image->resize(100, 100, ZEBRA_IMAGE_CROP_CENTER)) {

        // if there was an error, let's see what the error is about
        switch ($image->error) {

            case 1:
                echo 'Source file could not be found!';
                break;
            case 2:
                echo 'Source file is not readable!';
                break;
            case 3:
                echo 'Could not write target file!';
                break;
            case 4:
                echo 'Unsupported source file format!';
                break;
            case 5:
                echo 'Unsupported target file format!';
                break;
            case 6:
                echo 'GD library version does not support target file format!';
                break;
            case 7:
                echo 'GD library is not installed!';
                break;

        }

    // if no errors
    } else {

        echo 'Success!';

    }

?>

how can i display the images?

Recommended Answers

All 4 Replies

Does Zebra_Image() have any method for rendering/outputting the image data? if it does, you should be able to echo that out after setting the MIME type in the response with header("Content-type: image/jpeg"); or similar.

That suggestion only applies for outputting a single image as an image resource. If you need to output/display multiple images together then you need to create a HTML output which references each file separately.

I made a script with ob_clean() and header("Content-type: image/jpeg"); and i tried somehow to integrate the opendir() and the loop but i get errors.

The Zebra_Image() doesn't contain any header("Content-type: image/jpeg");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.