PhpChart as flat image - php

Is there a way to generate a flat image of my graph made with PhpChart in Php?
I know I can get the image in javascript using $(this).jqplotToImageElem(); but this doesn't help as I need to be able to put it into a PDF document I am creating in Php. I have tried using ajax to save the file to the server but the request URI is too long, so I really just need to generate the flat image in Php.

I thought I would write what work around I did for this in case anyone has the same issue. I created a POST form with a hidden input and once the page with the chart on it was loaded I used jQuery to put $(this).jqplotToImageElem().src; into the value of that input and then submit the form to the page needing the image. The receiving page can then use <img src="<?php $_POST['imagesrc'] ?>" /> to show the flat image of the chart, in my case I used the src in my pdf document.

Related

I am using a rich text editor that inserts images into mysqli database, I want to extract images into files

I'm using Summernote editor to collect user input, during this process users can insert images, the image data is then saved into mysql database using PHP & SQL, I want the ability to extract the file(s) from the database record, save the image then replace the image with url as an image tag.
I cannot find any posts that show how this can be achieved.
Here is a cut down from example record.
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJoAAACaCAYAAABR/1EXAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAACHDwAAjA8AAP1SAACBQAAAfXkAAOmLAAA85QAAGcxzPIV3AAAKLD9k7w7ivJbRkANSszRi8CgzmrKVwMC0gHCJi5PR/OcAiiQZFWxGqZuPIyGm3LhH6UtvKacCYyheltOgEH7xEcnsLp9JT0WVzEskyMItDViixhrypx0LCOARwc40pM8FunWS/T70+V/wPr/bssGCXNzQAAAABJRU5ErkJggg==" data-filename="alisonD_154x154.png" style="width: 25%;"><br></p>
To summarise, I want to be able to post process SQL records, when find images embedded, to save the data as an image file, replace the embedded image with a url which will point to the saved file.
Thanks david, you pointed me in the direction I needed, I will solve my problem using PHP DOM Parser. I've located this post which has the full solution.
Parse web pages with PHP Simple DOM Parser

Cakephp - Dynamicly save multiple jqplot images

I need to render and save multiple charts as images in a single function.
I already created the function to render the image. Also using javascript and ajax I made a functions to convert the graph to image and save it on the server (also adding watermark and text). But this works for 1 chart that you are viewing at the moment. What if I would like to save many charts in a single view?
Since the JQPLot chart is rendered on the client, The only option you have is to generate each chart, perhaps in a hidden div, convert it into a PNG file which you can later send to the server.
Or you can generate png's at runtime using js and keep on adding them to probably a comma separated hidden variable.

Seamless image replacement / update

I am creating a multi-layered image editor using AJAX to send calls to a PHP script, then using a GD library to process the changes, save the new image and send the new image path back to the browser for AJAX to replace old with new.
This example, when you move a layer it seamlessly moves the layer without a single flicker of the image. This example uses a dll file to serve the image, I want to be able to achieve the same thing in PHP / JS.
Idea 1
I thought about applying a z-index to the current image and load the new image below it, once it's loaded, hide the old image.
Idea 2
Set the image path to a php script which outputs the raw data of the compiled image direct to the browser.
if you want to replace the image "without a single flicker", just preload the image
(load the image to a hidden img element or a Image javascript object and then show it on an onload callback)

php image upload using ajax and display image after upload

I have the following scenario:
user selects an image to upload (simple form with input field where type="file")
File is upload to server (also Db is updated)
all this i already have..
I need to display the uploaded image on the page, upon success , without refresh.
Can this be done without iframes?
I have already done some ajax coding where input is saved to db or is used to return content from db.
The thing here is sending the actual file data from the field. Can I do this using jquery's $.get?
I was thinking that after copying the file and storing relevant data in the db i could return the new location (the path in the server where the file was copied). The jquery code catching this return could use it to set the src atribute of an img tag to the new file' thus displaying it.
Can you please recommend relevant tutorials or demos?
also, any tips would be very appreciated
u need javascript for that. Provide an onClick function with ur input type file element and in that function using javascripts createElement(), setAttribute(), appendChild etc functions to append the new image to the document object.
hope it helps
The best way to do this is to use a javascript-based AJAX upload function, and there are several javascript/jQuery plugins that do this. Check out this tutorial which explains one way of doing this using the ajaxupload.js plugin, for which you can find more documentation here.
I also wrote my own tutorial on this topic, including some PHP code that you need to save the image and other changes that I think are useful for beginners. You can find that here.
You can achieve this using AJAX with PHP and MYSQL. You can upload the image with AJAX and FormData, then validate and save the image in the server and send the URL of the image in a JSON response.
Note that the most important part of this is the validation.
See this beginner's guide to learn more.

Image layers cufon jquery php saving the resulting composite?

This question is a bit open at the moment as I'm not sure the idea is even possible.
So far I've loaded an image from a url, and then used jQuery UI draggable feature to allow the user to drag html text (which has been replaced using cufon font replacement) over the top of the image.
The major step (which is what my question relates to) is being able to take the image and text layered over the top of the image, and save the result, either to the server, or potentially offer the option to save the altered image to the user's HD, or what would also be useful is to upload to facebook using the facebook API, but this is something I know is possible.
It all hangs on whether it's even possible to achieve the first step, which is to save the image and layered text as a combined image?
I wonder if there is a PHP/jQuery solution that would allow me to do this?
My suggestion would be to have an internal URL that outputs the final image using jQuery and PHP, then take a screenshot using webkit2png of that page. You should know the dimensions etc., so you'll be able to crop down the resulting screenshot to just the region you're looking for.

Categories