What are the potential issues when returning both image data and ratio data in a PHP response?

Returning both image data and ratio data in a PHP response can lead to conflicts in the response format and potential data corruption. To solve this issue, it is recommended to separate the image data and ratio data into two separate responses or encode the data in a compatible format such as JSON.

// Separate the image data and ratio data into two separate responses
// Image response
header('Content-Type: image/jpeg');
echo $imageData;

// Ratio data response
header('Content-Type: application/json');
echo json_encode(['ratio' => $ratioData]);