duanlongling5308 2017-03-30 08:48 采纳率: 0%
浏览 21

php imagecropauto()不工作

I've written some code that copies a chunk of a big image to a new smaller image and saves it to the server. That all works just fine

However, I would like it to trim off any white background around the text and this is the part that doesn't work

Here is my code

$sourceImage = imagecreatefromjpeg($image); 
$tempImg = imagecreatetruecolor($data[2],$data[3]);
imagecopy($tempImg,$sourceImage, 0, 0, $data[0], $data[1], $data[2], $data[3]);
imagejpeg($tempImg,$destImage,90);
imagedestroy($tempImg);
chmod($destImage,0775);
// these next two lines don't work
$original_img = imagecreatefromjpeg($destImage);
$cropped_destImage = imagecropauto($original_img , IMG_CROP_THRESHOLD, 2, 16777215);

Can anyone see what I'm doing wrong here ?

Thanks

  • 写回答

2条回答 默认 最新

  • douhuibo5635 2017-03-30 09:10
    关注

    I have looked for you and this is what i found: PHP GD Text with Transparency/Alpha background

    This person had a similar problem. It could be worthwhile to read this topic because it has useful pieces of codes to deal with text that already has a background in it.

    评论

报告相同问题?

悬赏问题

  • ¥15 python变量和列表之间的相互影响
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)