Displaying MAgickWand modified images from POST

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
sambessey
Posts: 22
Joined: 2008-01-04T18:26:40-07:00

Displaying MAgickWand modified images from POST

Post by sambessey »

Hi,

I have a form which uses a JQUery POST command to submit the form contents to a PHP script. This works fine, but the PHP script is then supposed to be displayed on the page as an image (Using Image Magick/ Magick Wand). The problem is that when I post, I cannot get the new image to display with the updated form fields. For instance, if the user types "Hello" into a box, this should be written onto the image that is posted back to the screen (I want the POST just to update the image embedded on the page and nothing else).

Here is the JQuery I am using to read the form, and pass the configurable data over to PHP:

<script>

$(document).submit(function(){
var formTypes=new Array("cCOCR","cGR","fTIndex");
var values=new Array(formTypes.length);
var x=0;
var z =0;
for(var i=0; i<formTypes.length; ++i)
{
var input= $("input[name^=" + formTypes + "]");

values="";
for (x=0; x<input.length; x++)
{
var formval=$("input[name^=" + formTypes + x + "]").val();
values=values+escape(formval);

if (i ==2)
{
values=values+"!";
}

}
}

var cCOCR = values[0].replace(/#/g,"@");
var cGR = values[1].replace(/#/g,"@");
var fT = values[2];
$.post("render/imgEditNEW.php", { cCOCR: cCOCR,
cGR: cGR, fT: fT}, function(data) {
$("#status p").html("<IMG SRC='render/imgEditNEW.php'>");
});


return false;
});
</script>

$("#status p").html("<IMG SRC='render/imgEditNEW.php'>"); That is where I am trying to pass back the edited image, but all I get is the original image posted again. if I submit the form and just have it return text instead of an image, it works fine. (i.e. using $("#status p").html(data); )

But of couse if I use this, I get the text version of the PHP blob returned, as it is not enclosed in img tags.

Any ideas please?

Thanks
sambessey
Posts: 22
Joined: 2008-01-04T18:26:40-07:00

Re: Displaying MAgickWand modified images from POST

Post by sambessey »

I have realised this is pretty much impossible, as the doctype has to be image, but it is already set to html/ text. Therefore, the only solution is to write the file to a jpg or stream to another php file and load it in image tags and do a refresh using Javascript
Post Reply