im trying to send image to a webservice in php using json, but the client cnt read the image.. when i return it back!!
<?php
//recieve the image
$media = json_decode($_POST['media']);
header('content-type: image/jpeg');
$image = imagecreatefromjpeg($media);
imagefilter($image,IMG_FILTER_GRAYSCALE);
imagefilter($image,IMG_FILTER_COLORIZE,100,50,0);
imagejpeg($image, '', 90);
imagedestroy($image);
//return image
$response = array(
'image' => $image
);
echo json_encode($response);
?>
from the code, is there anything I'm doing wrong? Thanks!!! :))
Create a new Workbook object and open JSON file. Save JSON as JPEG using save method. Load JPEG document by using Image class. Save the document to JPEG2000 format using save method.
Just drag and drop your JSON file on upload form, choose the desired output format and click convert button. Once conversion completed you can download your JPG file. You even can perform more advanced conversions.
The JSON MIME type is application/json
, so you can't send image/jpeg
.
I think it would be easier to send the path to the image, and have your JavaScript make the request to the image.
Otherwise, I'm not sure how you are going to recreate that on the client. Date URIs are recommended to be base64 encoded, so if you insist on doing it like this, please call base64_encode()
first on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With