mraandrews Posted March 28, 2010 Share Posted March 28, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/196734-problem-with-imagejpeg-when-using-an-include/ Share on other sites More sharing options...
dreamwest Posted March 28, 2010 Share Posted March 28, 2010 include is a function <? header('Content-type: image/jpeg'); include('classes/utils/ImageResizer.class.php'); $image = imagecreatefromjpeg('img/1.jpg'); imagejpeg($image); ?> Quote Link to comment https://forums.phpfreaks.com/topic/196734-problem-with-imagejpeg-when-using-an-include/#findComment-1032918 Share on other sites More sharing options...
mraandrews Posted March 28, 2010 Author Share Posted March 28, 2010 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/196734-problem-with-imagejpeg-when-using-an-include/#findComment-1032927 Share on other sites More sharing options...
Tazerenix Posted March 28, 2010 Share Posted March 28, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/196734-problem-with-imagejpeg-when-using-an-include/#findComment-1032931 Share on other sites More sharing options...
mraandrews Posted March 28, 2010 Author Share Posted March 28, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/196734-problem-with-imagejpeg-when-using-an-include/#findComment-1032933 Share on other sites More sharing options...
Tazerenix Posted March 28, 2010 Share Posted March 28, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/196734-problem-with-imagejpeg-when-using-an-include/#findComment-1032934 Share on other sites More sharing options...
mraandrews Posted March 28, 2010 Author Share Posted March 28, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/196734-problem-with-imagejpeg-when-using-an-include/#findComment-1032935 Share on other sites More sharing options...
Tazerenix Posted March 28, 2010 Share Posted March 28, 2010 <?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 Quote Link to comment https://forums.phpfreaks.com/topic/196734-problem-with-imagejpeg-when-using-an-include/#findComment-1032936 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.