duanchui1279 2013-10-08 09:16
浏览 132
已采纳

使用PHP裁剪图像

I want to cut a picture from Google Charts.

My Code is:

$org_img = "http://chart.googleapis.com/chart?chxl=0:|14%3A00|17%3A00|1:|11|11|11|2:|+&chxp=0,0,1|1,0,1,2&chxr=0,0,8|1,0,8|2,-5,25.5&chxs=0,676767,10,-1,t,FFFFFF|1,676767,10.1,-1,_,676767|2,676767,0,0,_,676767&chxtc=0,2&chxt=x,t,y&chs=515x120&cht=lc&chco=FFCC00&chds=-40,40&chd=t:11,11,11,11,11,11,11,11&chdlp=l&chg=-1,-1,0,1&chls=4&chm=B,FFCB0033,0,0,0,1";
$crop = 40;
$xy_org = getimagesize($org_img);
$x_new = $xy_org[0] - $crop;
$y_new = $xy_org[1] ;
$tmp_img = imagecreatetruecolor($x_new, $y_new);
$src_img = imagecreatefrompng($org_img);
imagecopy($tmp_img, $src_img, 0, 0, $crop, $crop, $x_new, $y_new);
header ("Content-type: image/png");
echo "<img src = '".imagepng($tmp_img, '', 100)."'>";
imagedestroy($tmp_img);

The Problem now is, that i allways get an error in the browser: Resource interpreted as Document but transfered with MIME Type image/png.

Can anybody help me to cut an image ?

I acctually want to cut at the beginning 2 pixel and at the end 2px.

Thanks for your answer.

  • 写回答

1条回答 默认 最新

  • du16178 2013-10-08 09:26
    关注

    Replace echo "<img src = '".imagepng($tmp_img, '', 100)."'>"; with imagepng($tmp_img);.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#lua#的问题,请各位专家解答!
  • ¥15 什么设备可以研究OFDM的60GHz毫米波信道模型
  • ¥15 不知道是该怎么引用多个函数片段
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题