为什么Content-Type:image/jpeg标头不起作用? [英] Why is Content-Type: image/jpeg header not working?
本文介绍了为什么Content-Type:image/jpeg标头不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用GD库调整图像大小.为什么header('Content-Type: image/jpeg');
不起作用?
I'm using GD library to resize image. Why is not header('Content-Type: image/jpeg');
working?
它给了我一个错误,如下图所示:
It gave me an error as you can see in pic below:
这是我的GD详细信息:
Here are my GD details:
.
<?php
header("Content-type: image/jpeg");
if(isset($_GET['image'])){
$image = $_GET['image'];
list($image_width, $image_height)= getimagesize($image);
$new_size = ($image_width+$image_height)/($image_width*($image_height/45));
$new_width = $image_width * $new_size;
$new_height = $image_height * $new_size;
$new_image = imagecreatetruecolor($new_width, $new_height);
$old_image = imagecreatefromjpeg($image);
imagecopyresized($new_image, $old_image, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height);
imagejpeg($new_image);
}
?>
推荐答案
使用现有脚本/库而不是重新发明轮子总是更好的选择……尝试使用timthumb或类似方法……这样可以节省很多时间和错误无误...
It would always better to use the existing scripts/libraries instead of reinventing the wheel... try using timthumb or similar... that would save a lot of time and error free...
http://www.phpguy.in/simple在php/
这篇关于为什么Content-Type:image/jpeg标头不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文