一个函数php生成的图片上的wget

一个函数php生成的图片上的wget,php,shell,wget,Php,Shell,Wget,我在某些if条件下触发了此exec: exec('( [ ! -e "ha45_temp" ] && touch ha45_temp && wget http://localhost/index.php/Montor/makeApiCameraPrintscreen?id='.$insert_id .' -O ./images/'. $insert_id.' > /dev/null 2>&1 && sleep 30 &&

我在某些if条件下触发了此exec:

exec('( [ ! -e "ha45_temp" ] && touch ha45_temp && wget http://localhost/index.php/Montor/makeApiCameraPrintscreen?id='.$insert_id .' -O ./images/'. $insert_id.' > /dev/null 2>&1 && sleep 30 && rm ha45_temp ) > /dev/null 2>&1 &');
我正在从主控制器调用makeApiCameraPrintscreen方法,并将其输出定向到以下路径:-O./images/,名称为$insert\u id(我在该变量中保留一个唯一的id来命名图片)

方法如下:

public function makeApiCameraPrintscreen(){
    $imagename = $this->input->get('id', TRUE);
    $datasidget = $this->curl->simple_get('somepictureapi');
    $datasid = json_decode($datasidget,true);
    $data_sid =  $datasid['data']['sid'];
    $reqUrl = "somepictureapi";
    $imageencode = $this->curl->simple_get($reqUrl);
    $this->output->set_content_type('jpeg');
    $this->output->set_output($imageencode);

    }
我的问题是,我的wget保存了一个二进制八位字节流文件(该二进制文件是来自图像的,但扩展名不正确)

这是一条线的例子。现在的问题是,我不确定我会得到jpeg格式(内容类型)的图片,但我尝试与jpg/png相同的输出

我想做的是将wget中的图片以适当的格式保存,以便打开它

PS1。对于Mark:

00000000: 0aff d8ff fe00 104c 6176 6335 362e 3630  .......Lavc56.60
00000010: 2e31 3030 00ff db00 4300 080a 0a0b 0a0b  .100....C.......
00000020: 0d0d 0d0d 0d0d 100f 1010 1010 1010 1010  ................
00000030: 1010 1012 1212 1515 1512 1212 1010 1212  ................
00000040: 1414 1515 1717 1715 1515 1517 1719 1919  ................
00000050: 1e1e 1c1c 2323 242b 2b33 ffc4 01a2 0000  ....##$++3......
00000060: 0105 0101 0101 0101 0000 0000 0000 0000  ................
00000070: 0102 0304 0506 0708 090a 0b01 0003 0101  ................
00000080: 0101 0101 0101 0100 0000 0000 0001 0203  ................
00000090: 0405 0607 0809 0a0b 1000 0201 0303 0204  ................

您是否尝试将所有输出保存到jpg文件中?这应该行得通是的,我在我的帖子中说过“但是我试着用jpg/png相同的输出”试着运行
xxd YourImage|head-10
,然后在你的问题下点击
edit
,复制并粘贴到输出中,然后我们可以看到数据的十六进制格式,并告诉你。@MarkSetchell Ok,我想你在图像的开头有一个多余的换行符(
0a
),在你的PHP中的某个地方,在你输出图像之前,你先输出一个换行符。
00000000: 0aff d8ff fe00 104c 6176 6335 362e 3630  .......Lavc56.60
00000010: 2e31 3030 00ff db00 4300 080a 0a0b 0a0b  .100....C.......
00000020: 0d0d 0d0d 0d0d 100f 1010 1010 1010 1010  ................
00000030: 1010 1012 1212 1515 1512 1212 1010 1212  ................
00000040: 1414 1515 1717 1715 1515 1517 1719 1919  ................
00000050: 1e1e 1c1c 2323 242b 2b33 ffc4 01a2 0000  ....##$++3......
00000060: 0105 0101 0101 0101 0000 0000 0000 0000  ................
00000070: 0102 0304 0506 0708 090a 0b01 0003 0101  ................
00000080: 0101 0101 0101 0100 0000 0000 0001 0203  ................
00000090: 0405 0607 0809 0a0b 1000 0201 0303 0204  ................