PHP crop and resize image on the fly

css, html, php

Solution

WideImage rlz! :)

The resize's like that:

header('Content-type: image/jpeg');

echo WideImage::load('image.jpg')->resize(200, 100)->asString('jpg', 80);
// image.jpg resized at 200x100 with 80% of quality

Problem

I have a web page that displays images that I don't know their size in advance. I was trying to use the GD functions to make the script resize and crop the images from me " Just before they are displayed.. I don't need caches" but I failed. I need a script that I can call like this ``` <img src="display.php?src=blablabla&height=100&width=200" ?> ``` or even by calculating the width and height of css to preserve the proportions and make the image touch the box from inside like ``` <img src="blabla.jpg" style="height:<?php echo $height; ?>; width:<?php echo width; ?>" /> ``` I don't need any sort of caching. How can I do that ?

Original source