I'm very annoyed with this error :
If I comment out the
require_once'../class/myclass.class.php';
the image is displayed. If I un-comment my line calling myclass.class.php, I have this message:
"The image "http://..." cannot be displayed because it contains errors."
My code is simple:
myclass.class.php :
<?php
class myclass {
public function getPanelData( $model ){
$aFieldsData = array(
'PAN35'=>array(
'col'=>1,
'row'=>3,
'v-font'=>10,
'v-marge-top'=>0,
'v-marge-right'=>1,
'v-marge-bottom'=>0,
'v-marge-left'=>1
)
);
if( key_exists($model, $aFieldsData) )
return $aFieldsData[$model];
else
return false;
}
}
?>
img.inc.php:
<?php
session_start();
require_once('myfunctions.inc.php');
require_once('../class/myclass.class.php');
$oData = new myclass();
header('Content-Type: image/png');
$sPanelModel = $_SESSION['produit'];
$sEtiquette = '../img/etiquettes/label_'.$sPanelModel.'_preview.png';
$rImg = imagecreatefrompng($sEtiquette);
imagepng($rImg);
imagedestroy($rImg);
?>
Note: This code works if I comment require_once calling myclass.class.php. Calling functions.inc.php works (only few functions).
tree :
/
+ class
+ myclass.class.php
+ inc
+ functions.inc.php
+ img.inc.php
+ images
+ etiquettes
If it is true that it works by uncommenting the require() for myclass.class.php, then the most likely cause is this file contains blank lines (whitespace) before the <?php or after the ?>. This would add Ascii characters to the output of the image, or insert a php error message (Headers could not be sent) on your header() statement and thus mess up your file.
However, as I mentioned in my comment, if your sole purpose is to output the picture you could use readfile() instead of creating an image instance.
Hope that helps,
Stefan
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