[imp] GD picture in IMP (quotabar)

Krystian Filiks filiks at telesonique.com
Thu Sep 16 09:51:57 PDT 2004


Hello,

I'm trying to generate a quotabar using PHP+GD but fail upon putting the
"header(Content-Type: image/png)" in to the header.inc file.

Below find the relevant part of the header.inc template, as soon as I
uncoment the // header("Content-type: image/png"); ?>
I get an error that the page could not be loaded as it contains errors.

If I keep the header("Content-type: image/png"); ?> commented then it works
fine just that the picture is displayed as text and not picture.

I know that the header("Content-type: image/png"); directive must be present
if I want to display the generateg PNG picture.

 Any ideas ho to make this work??

<?php if (!$prefs->isLocked('filters')): ?>
        <?php echo Horde::link(Horde::applicationUrl("mailbox.php?actionID="
. FILTER . "&page=$page&uniq=" . uniqid(rand())), sprintf("%s %s", _("Apply
Filters on"), $imp['label']), 'menuitem') . Horde::img('filters.gif',
'alt="' . sprintf("%s %s", _("Apply Filters on"),
htmlspecialchars($imp['label'])) . '"') ?></a>&nbsp;
////////////////////////////////////////////////////////////////////////////
///////////
<?php  $style_dir = '/var/www/html/progress/'; ?>
<?php  $style = 'osx'; ?>
<?php  $width = '250'; ?>
<?php  $done = '45'; ?>
<?php  $total = '100'; ?>
<?php $bg       = @imagecreatefrompng($style_dir . $style . '-bg.png'); ?>
<?php $fill     = @imagecreatefrompng($style_dir . $style . '-fill.png'); ?>
<?php $bg_cap   = @imagecreatefrompng($style_dir . $style . '-bg-cap.png');
?>
<?php $fill_cap = @imagecreatefrompng($style_dir . $style .
'-fill-cap.png'); ?>
<?php $fill_width = round((($width - imagesx($bg_cap)) * $done) / $total) -
imagesx($fill_cap); ?>
<?php $image = imagecreatetruecolor($width, imagesy($bg)); ?>
<?php imagecopy($image, $bg, 0, 0, 0, 0, imagesx($bg), $width -
imagesx($bg_cap)); ?>
<?php imagecopy($image, $bg_cap, $width - imagesx($bg_cap), 0, 0, 0,
imagesx($bg_cap), imagesy($bg_cap)); ?>
<?php imagecopy($image, $fill, 0, 0, 0, 0, $fill_width, imagesy($fill)); ?>
<?php imagecopy($image, $fill_cap, $fill_width, 0, 0, 0, imagesx($fill_cap),
imagesy($fill_cap)); ?>
<?php // header("Content-type: image/png"); ?>
<?php imagepng($image, "testquota.png"); ?>
<?php imagedestroy($bg); ?>
<?php imagedestroy($fill); ?>
<?php imagedestroy($bg_cap); ?>
<?php imagedestroy($fill_cap); ?>
<?php imagedestroy($image); ?>
////////////////////////////////////////////////////////////////////////////
///////////////

<?php endif; ?>......


More information about the imp mailing list