0

So my plan is instead of adding a style to each picture or making different images with different sizes, I made this script:

/*FILENAME image.php*/
    if(isset($_GET['size'])){
        $image['size']  = $_GET['size'];
        $size = explode('x', $image['size']);
        $image['width'] = $size[0];
        $image['height'] = $size[1];
    } else {
        $image['size']  = null;
    }
echo "<img src='images/".$image['name'].".jpeg' style='width:".$image['width'].";   height:".$image['height'].";'>";

But it doesn't work, In one of my scripts, I have this:

echo '<img id="img_01" src="image.php?name='.$row2['name'].'&size=150x160" data-zoom-image="image.php?name='.$row2['name'].'&size=150x160"/>';

And the browser echo's just a missing image. How could I make my script work? I know there must be a way because I remember doing something like this with an open source.

1 Answer 1

1

That's not how dynamic images work. Image.php has to actually output the raw binary content of an image (open a jpg file in a text editor, that's what the PHP file should generate).

Take a look at the gd functions, like http://www.php.net/manual/en/function.imagecopyresized.php, which should have some examples that will help

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.