Jump to content

Recommended Posts

After working on this for a while, I realized I couldn't save the output image, although the image displays in the browser perfectly fine.  When I try to open the file in windows it says the format of the file can't be determined, and checking the properties in my browser, I notice the file is only 68 bytes.

 

I trimmed my code slowly to try and figure out where the problem was, until I got all the way back to the start, and it still gives me the same problem.

 

Am I missing something in the basic steps to create an image?

 

<?php
$image=imagecreatefromjpeg('test.jpg');
header('Content-type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
?>

When you open the saved file using a programing editor, what exactly is in it?

 

How are you browsing to this file or what does the link look like in your html?

 

What you are doing works, so it must be something specific to what or how you are doing it.

How are you browsing to this file or what does the link look like in your html?

This clued me in to my problem.

 

Originally, I was having a problem with the headers, and while trying to figure that out, the php code ended up outside of any html on the page the image gets displayed on (which is a redirect from a first page, which is also why I was having the header problem).

 

Anyway, that made me figure out what my problem was, thanks!

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.