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 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签)
  • ¥50 sft下载大文阻塞卡死
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失
  • ¥15 springboot+vue 集成keycloak sso到阿里云
  • ¥15 win7系统进入桌面过一秒后突然黑屏
  • ¥30 backtrader对于期货交易的现金和资产计算的问题