I have a code that dinamically resizes an image and sends it to the browser.
But it doesn't work properly... only if I ask it to output the image to a file instead of the browser.
I don't think the problem is my code, because this problem only occurs on the real server; in my computer its working perfectly.
Code:
$img = $_GET['img'];
ini_set('allow_url_fopen', 'on');
$info = getimagesize($img);
header('Content-type: '.image_type_to_mime_type($info[2]));
Fotos::redimensiona($img, null, Fotos::MINIGAL_WIDTH, Fotos::MINIGAL_HEIGHT, false);
Fotos::redimensiona():
//[...] a whole bunch of code calculating dimensions, they just works
// $funcImage is like 'imagejpeg'/'imagepng'/'imagegif', depends on file
if ($arquivo) {
$funcImage($thumb, "$final.$ext");
return "$final.$ext";
}
else {
$funcImage($thumb);
}
Remember: it works on local development, but doesn't on remote web server.
[EDIT]
if I comment the header
line, the binary code is printed; and this code changes when i change the original image, as expected.
But with the header
Firefox shows me the URL of the page (like http://www.sabianoar.com.br/novosabia/inc/phpImg.php?img=awful_escaped_long_path.jpeg
), and if I do CTRL+I
it tells me it is an JPEG of 0x0 size, and like 10kb.
Opera shows me an empty image, as it would do if I had placed an <img>
with the wrong src
, i.e.
[EDIT2] EyeOfGnome says "Not a JPEG file: starts with 0xef 0xbb" when I try to save and then open the output (it saves to a .jpeg file normally).