无法显示图像,因为它在使用imagecreatefromstring后包含错误

first, i try to get image content from API. The api return binary string. i have try and execute my code, and show "image cannot be displayed because it contains errors".

here is my code :

<?php
      // Your ID and token

      $authToken = 'Bearer {mytoken}';







      // Setup cURL
      $ch = curl_init('https://api.line.me/v2/bot/message/512370463/content');
      curl_setopt_array($ch, array(
        CURLOPT_SSL_VERIFYPEER => false,
          CURLOPT_POST => false,
            CURLOPT_HEADER => false,
          CURLOPT_RETURNTRANSFER => TRUE,
           CURLOPT_BINARYTRANSFER => true,
          CURLOPT_HTTPHEADER => array(
              'Authorization: '.$authToken,
          )

      ));

      // Send the request
      $response = curl_exec($ch);

      header('Content-Type: image/jpeg;');





      $im = imagecreatefromstring($response );
      var_dump($im);die();
      $gambar = imagejpeg($im);
      var_dump($gambar);die();





      // // Check for errors
      // if($response === FALSE){
      //     die(curl_error($ch));
      // }

      // // Decode the response
      // $responseData = json_decode($response, TRUE);
      // print_r($responseData);
      // // Print the date from the response

      ?>

thanks for your response :)