See Example #1 and #2, imagejpeg will output the jpeg data.
You need to do few tings:
- set headers for image
header('Content-Type: image/jpeg');
- output your image data
- Make sure you are not outputting any data except the image
At the end you should end up with something like this:
<?php
// Get new dimensions
// Resample
// etc...
// set header so browser can render image properly
header('Content-Type: image/jpeg');
// Output
imagejpeg($image, null, xxx);
// [or]
echo file_get_contents($pathToJpgImage);
If you find your self in a situation where current request outputs data and you cannot output image... You can inject the base64 encoded image data into the HTML by using
<img src="data:image/jpeg;base64,..." />. See
php documentation on base64_encode for images.
echoanywhere should do that.