Jump to content

[SOLVED] Several 'headers'


mrcodex

Recommended Posts

I've read FAQ and tried several things, but can not get this to work ...

 

How get I use several e.g. GD 2 scripts at the same page? like this:

 

<?php

$im = imagecreatetruecolor(120, 20);

$text_color = imagecolorallocate($im, 233, 14, 91);

imagestring($im, 1, 5, 5,  'test1', $text_color);

header('Content-type: image/jpeg');

imagejpeg($im, NULL, 75);

imagedestroy($im);

 

$im = imagecreatetruecolor(120, 20);

$text_color = imagecolorallocate($im, 233, 14, 91);

imagestring($im, 1, 5, 5,  'test2', $text_color);

header('Content-type: image/jpeg');

imagejpeg($im, NULL, 75);

imagedestroy($im);

?>

 

I'm new at PHP, jumping right from ASP ...

 

rgrds,

 

Link to comment
https://forums.phpfreaks.com/topic/128246-solved-several-headers/
Share on other sites

It's mainly to crop images. I have a chat-script (shoutbox kind) that display the chat-text and image of the user. Now I have locked the size of the user-images, but I want to crop them to get the right aspect/ size for my site. I've found several crop-script, but get stuck on the header-thing. So I thought of trying out a simple GD example first. I want to crop and display them instead of crop and save.

 

thx

You need to use the <img> tag specifying a php script as the src. It can be the same script.

 

Example:

<?php
if (isset($_GET['im'])) {
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  $_GET['im'], $text_color);
header('Content-type: image/jpeg');
imagejpeg($im, NULL, 75);
imagedestroy($im);
exit();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title>PHP Image Test</title>
</head>
<body>
<img src="?im=test1"><br><img src="?im=test2">
</body>
</html>

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.