Save image to file fails
-
- Newbie
- Posts: 22
- Joined: Tue Apr 30, 2013 12:00 am
Save image to file fails
Save image to file produces error and the image is not saved to the path/directory as it was in the evaluation version, even from the TeeChart samples..
Warning: imagepng(): 247 is not a valid Image resource in C:\xampp\htdocs\...........\sources\exports\PNGFormat.php on line 50
The Chart has been exported correctly !
I am guessing this code found as shown commented out in sources/exports/ImageExportFormat.php likely has some involvement..
/*
public function save($fileName) /*throws IOException {
$outfile = new File($fileName);
$ios = $this->ImageIO->createImageOutputStream($outfile);
$this->save2($ios);
$ios->close();
}
*/
public function save($ios) /* TODO throws IOException*/ {
}
AND...
Export SVG results in a page full of repeating errors (short list below):
Notice: Undefined variable: X in C:\xampp\htdocs\..........\sources\drawing\CanvasSVG.php on line 642
Notice: Undefined variable: Y in C:\xampp\htdocs\...........\sources\drawing\CanvasSVG.php on line 642
Warning: Missing argument 4 for CanvasSVG::TextOut(), called in C:\xampp\htdocs\..........\sources\drawing\CanvasSVG.php on line 642 and defined in C:\xampp\htdocs\CPDT\CPDT_lite\charts\sources\drawing\CanvasSVG.php on line 592
Notice: Undefined variable: text in C:\xampp\htdocs\..........\sources\drawing\CanvasSVG.php on line 605
Notice: Undefined variable: text in C:\xampp\htdocs\...........\sources\drawing\CanvasSVG.php on line 606
Notice: Undefined variable: text in C:\xampp\htdocs\...........\sources\drawing\CanvasSVG.php on line 632
Notice: Undefined variable: X in C:\xampp\htdocs\...........\sources\drawing\CanvasSVG.php on line 642
Notice: Undefined variable: Y in C:\xampp\htdocs\...........\sources\drawing\CanvasSVG.php on line 642
Etc, etc.
Warning: imagepng(): 247 is not a valid Image resource in C:\xampp\htdocs\...........\sources\exports\PNGFormat.php on line 50
The Chart has been exported correctly !
I am guessing this code found as shown commented out in sources/exports/ImageExportFormat.php likely has some involvement..
/*
public function save($fileName) /*throws IOException {
$outfile = new File($fileName);
$ios = $this->ImageIO->createImageOutputStream($outfile);
$this->save2($ios);
$ios->close();
}
*/
public function save($ios) /* TODO throws IOException*/ {
}
AND...
Export SVG results in a page full of repeating errors (short list below):
Notice: Undefined variable: X in C:\xampp\htdocs\..........\sources\drawing\CanvasSVG.php on line 642
Notice: Undefined variable: Y in C:\xampp\htdocs\...........\sources\drawing\CanvasSVG.php on line 642
Warning: Missing argument 4 for CanvasSVG::TextOut(), called in C:\xampp\htdocs\..........\sources\drawing\CanvasSVG.php on line 642 and defined in C:\xampp\htdocs\CPDT\CPDT_lite\charts\sources\drawing\CanvasSVG.php on line 592
Notice: Undefined variable: text in C:\xampp\htdocs\..........\sources\drawing\CanvasSVG.php on line 605
Notice: Undefined variable: text in C:\xampp\htdocs\...........\sources\drawing\CanvasSVG.php on line 606
Notice: Undefined variable: text in C:\xampp\htdocs\...........\sources\drawing\CanvasSVG.php on line 632
Notice: Undefined variable: X in C:\xampp\htdocs\...........\sources\drawing\CanvasSVG.php on line 642
Notice: Undefined variable: Y in C:\xampp\htdocs\...........\sources\drawing\CanvasSVG.php on line 642
Etc, etc.
Re: Save image to file fails
Hi,
Could you please arrange a simple example project we can run as is to reproduce the problem here?
Thanks in advance.
Could you please arrange a simple example project we can run as is to reproduce the problem here?
Thanks in advance.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 22
- Joined: Tue Apr 30, 2013 12:00 am
Re: Save image to file fails
Well this is a fresh download, and just using your examples under exporting>pictures (pick any of them, jpeg, png, etc) produces the error.
-
- Newbie
- Posts: 22
- Joined: Tue Apr 30, 2013 12:00 am
Re: Save image to file fails
I might add, it worked in the evaluation version download.
-
- Newbie
- Posts: 22
- Joined: Tue Apr 30, 2013 12:00 am
Re: Save image to file fails
In sources/exports/PNGFormat.php as well as the other image exports, you reference this variable --> $ios (ImageOutputStream)
Like so..
The only other place I can find that variable, and where it is supposed to be defined, it seems, is at the bottom of sources/exports/ImageExportFormat.php
Below is copy/paste from ImageExportFormat.php exactly as it exists in my file (commented out -- not by me). Is there somewhere else $ios is defined?
Now in that code above, you also reference a variable --> $fileName I cannot find where that is defined. And I note that the errors thrown are like "247 is not a valid image resource". That number "247" is not coming from me, I simply click the button in your image export samples to save file and that error arrives. So where is that number generated?
Like so..
Code: Select all
public function save($ios) /* TODO throws IOException*/ {
if ($this->width <= 0) {
$this->width = 400;
}
if ($this->height <= 0) {
$this->height = 300;
}
$img = $this->chart->image($this->width, $this->height);
imagepng($this->chart->getGraphics3D()->img,$ios);
}
Below is copy/paste from ImageExportFormat.php exactly as it exists in my file (commented out -- not by me). Is there somewhere else $ios is defined?
Code: Select all
/*
public function save($fileName) /*throws IOException {
$outfile = new File($fileName);
$ios = $this->ImageIO->createImageOutputStream($outfile);
$this->save2($ios);
$ios->close();
}
*/
public function save($ios) /* TODO throws IOException*/ {
}
}
Re: Save image to file fails
Hi,
I've reproduced this with the latest TeeChart version. We're currently investigating it.
I've reproduced this with the latest TeeChart version. We're currently investigating it.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Save image to file fails
Hello,
you were correct, the problem was just on our examples. As you added a destroy on our latest source code, once the render() method is called (this was to liberate memory in the case anyone wants to render chart several times).
This changes the way the charts have to be exported to a images, it's juts about lines order related, you have to call the export method before the render method (in the case of the available examples), for example :
We've already changed this for the demos.
you were correct, the problem was just on our examples. As you added a destroy on our latest source code, once the render() method is called (this was to liberate memory in the case anyone wants to render chart several times).
This changes the way the charts have to be exported to a images, it's juts about lines order related, you have to call the export method before the render method (in the case of the available examples), for example :
Code: Select all
$points->fillSampleValues(30);
// Save Chart to text
if(isset($_POST['submit'])) {
if ($path!="") {
if (realpath($path)) {
$chart1->doInvalidate();
$chart1->getChart()->getExport()->getImage()->getPNG()->save($path."\\TChart.png");
echo "The Chart has been exported correctly <br> !";
}
}
else
{
echo "Correct path must be entered ! ";
}
}
$chart1->render("chart1.png");
Pep Jorge
http://support.steema.com
http://support.steema.com
-
- Newbie
- Posts: 2
- Joined: Thu Jul 03, 2014 12:00 am
Re: Save image to file fails
I know this is an old thread. But I have just downloaded the Jul-2013 version and I found that the image export bug is still there. I had the getExport() after render() in my code with the evaluation version, but the code crashes with this latest registered version - for the reason I now understand from this thread. I have not seen this important change highlighted in the version upgrade documentation.
By the way, if you getExport() before render() as advised, and you try to print the chart you see on screen into a .pdf file, you get no image - it's all black. To get a print, you need to first render() before getExport().
Another observation is that the charts I produce from the evaluation version are visibly better than from the latest registered version. With this latest version the legend lines look squashed between the rule lines. I will probably stay with the evaluation version for now.
By the way, if you getExport() before render() as advised, and you try to print the chart you see on screen into a .pdf file, you get no image - it's all black. To get a print, you need to first render() before getExport().
Another observation is that the charts I produce from the evaluation version are visibly better than from the latest registered version. With this latest version the legend lines look squashed between the rule lines. I will probably stay with the evaluation version for now.
Re: Save image to file fails
Hello,
We made changes in the sources recently. I'll send you the latest sources and demos by mail so you can check if they work fine for you.
We made changes in the sources recently. I'll send you the latest sources and demos by mail so you can check if they work fine for you.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 2
- Joined: Thu Jul 03, 2014 12:00 am
Re: Save image to file fails
Look at the attached .png files which compare the quality of charts from the 2010 version and your very latest (May-2014) version. You can see that the chart Legend in the 2014 version shows the lines separating the legend texts actually touching the texts. The chart from the 2010 version is of better quality.
- Attachments
-
- Legend lines are not adequately spaced for the legend texts
- TChart2014-Sample.png (66.68 KiB) Viewed 69536 times
-
- Crisp and clear Legend -lines are optimally spaced
- TChart2010-Sample.png (71.4 KiB) Viewed 69507 times
Re: Save image to file fails
Hello,
Thanks for reporting this.
We've made a few changes and fixed this problem with the legend.
I'll send you the new sources to the mail account you have registered in this forum.
Thanks for reporting this.
We've made a few changes and fixed this problem with the legend.
I'll send you the new sources to the mail account you have registered in this forum.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |