Jump to content

Recommended Posts

I wrote this little test script:

 

<?

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

include_once 'classes/utils/ImageResizer.class.php';

 

$image = imagecreatefromjpeg('img/1.jpg');

imagejpeg($image);

?>

 

but it doesn't work.  If I take out the include it seems fine, is there another way round this as the include will be an object for image manipulation

 

mARK

Thankyou for the responds, but could you elaborate on your answer a little please...

 

include is a function

 

<?
header('Content-type: image/jpeg');
include('classes/utils/ImageResizer.class.php');

$image = imagecreatefromjpeg('img/1.jpg');
imagejpeg($image);
?>

include is a function

 

<?
header('Content-type: image/jpeg');
include('classes/utils/ImageResizer.class.php');

$image = imagecreatefromjpeg('img/1.jpg');
imagejpeg($image);
?>

 

and if you knew anything you would know that include is a special function in php that doesnt require parenthesis, like echo.

 

Try changing the include line to below where the $image variable is defined. If it is above it cant really do anything to the $image handler as it hasnt been defined when the page has been included

I know what does and doesn't need brackets, but I write code to standards cause I work with other people and that has been agreed how it will be done.  and as that has nothing to do with the question and is nothing more than a vain attempt to enhance your ego, I will disregard it....  I came to this forum to ask for help, not to have some one to tell me how to write the syntax of my code...

 

and if you had listened to my original question I want to carry out the image manipulation in a method of a PHP object, therefore the declaration will have to be the first thing, so thank you very little... 

 

include is a function

 

<?
header('Content-type: image/jpeg');
include('classes/utils/ImageResizer.class.php');

$image = imagecreatefromjpeg('img/1.jpg');
imagejpeg($image);
?>

 

and if you knew anything you would know that include is a special function in php that doesnt require parenthesis, like echo.

 

Try changing the include line to below where the $image variable is defined. If it is above it cant really do anything to the $image handler as it hasnt been defined when the page has been included

You're really missing the point, the script I posted, as I said, was a test script to demonstrate the problem, I know that I will need to define the object with a statement like $im = new ImageResizer() and them call a method on the instance of that object  like $im.resize($image, $scale)....

 

If you're not going to help answer the question, then please don't post anymore, the question I asked was clear and concise...  I want to use an object for image manipulation, but the include stops it from working.  Why? and how to get round this?

 

if you want to carry out the resizing through a method of a class then your going to need to call the method. You can just have the method defined in the class.

<?php

require("./classes/utils/ImageResizer.class.php");

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

$image = imagecreatefromjpeg('img/1.jpg');

imagejpeg($image);

?>

 

If that doesnt work then remove the header function and add error_reporting(E_ALL); to the top of your script to see if anything is happening wrong. Calling header("Content-type: image/jpeg"); will hide any errors after it as an image cant display text in a browser

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.