Returning a numeric value and an image - Printable Version -Shoutbox (https://shoutbox.menthix.net) +-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58) +--- Forum: Skype & Technology (/forumdisplay.php?fid=9) +---- Forum: Tech Talk (/forumdisplay.php?fid=17) +----- Thread: Returning a numeric value and an image (/showthread.php?tid=89796) Returning a numeric value and an image by MeEtc on 03-21-2009 at 05:43 PM
I'm working on a new image editor for YASS, and I've run into a problem with positioning text. Text is being generated with PHP as an image. The problem I'm facing, is in the actual image text position is based on the baseline of the text, and letters with underhang (jgy etc.) are placed below the vertical position of the text. On the editor, all the different elements are being generated as independent images. When images with the text are generated, the bottom of the image ends up being the vertical alignment, and basically all the text is higher than its supposed to be. What I am trying to do, is somehow send the HTML page embedding the image (and the JavaScript in the page) a numeric value that shows how much the image should be offset by vertically, how much lower it should be moved. RE: Returning a numeric value and an image by Matti on 03-21-2009 at 05:53 PM
What about letting your PHP script produce data as JSON? Something like: code: RE: Returning a numeric value and an image by MeEtc on 03-21-2009 at 06:02 PM Hm, now thats an interesting idea. How would I get Javascript in the browser to display the image though? Right now I'm using new Image(), setting a src, and appending as a child node for the initial loading of the page. I haven't added in the dynamic updating yet, but should be easy enough just to change the src and position as needed. So yeah, ho do I get the image data from a JSON into an IMG tag? RE: Returning a numeric value and an image by WDZ on 03-21-2009 at 08:24 PM
XMLHttpRequest lets you access HTTP response headers, right? php code: js code: RE: Returning a numeric value and an image by MeEtc on 03-21-2009 at 08:51 PM
Thanks WDZ. I'll see if that can work with what I have, because I don't use XMLHTTPRequest to load the image. I was also speaking with Matti offline, he suggested returning a JSON with the offset and a URL to a cache that has the image to be loaded. RE: Returning a numeric value and an image by WDZ on 03-21-2009 at 09:23 PM
quote:Good question... I didn't think that through before posting. I just thought using a header would be easier than wrapping everything in JSON like Matti suggested. You might be able to do it using a data: URI... js code: That code would require the image data to be base64-encoded on the server side. It might work without encoding too, but you can test that yourself. RE: Returning a numeric value and an image by MeEtc on 03-21-2009 at 09:36 PM
yeah, i was thinking using that earlier too. Encoding it with base64 isn't difficult |