modding the church sign generator
July 10, 2005 8:36 AM Subscribe
I'm trying to modify the great Church Sign Generator for my own purposes. I have a php question...
If I wanted the resulting merged image to be written to a file on the server, say, sign.jpg, instead of being displayed in a new window, how would I modify the php to do that?
I don't need every submitted sign to be written to a unique filename. I just need the same file overwritten every time a sign is submitted.
I assume this is the part of the source code that would be replaced by something different:
+++++++++++++++++++++++++++++++++++++++++++++
/* Now that the image is built, it gets sent to the browser. First, send out HTTP headers to
tell the browser a JPEG image is coming. */
header("Content-Type: image/jpeg");
header("Content-Disposition: inline; filename=churchsign.jpg");
/* The imagejpeg() function sends the output img to the browser. */
imagejpeg($output_img);
++++++++++++++++++++++++++++++++++++++++++++++
??
If I wanted the resulting merged image to be written to a file on the server, say, sign.jpg, instead of being displayed in a new window, how would I modify the php to do that?
I don't need every submitted sign to be written to a unique filename. I just need the same file overwritten every time a sign is submitted.
I assume this is the part of the source code that would be replaced by something different:
+++++++++++++++++++++++++++++++++++++++++++++
/* Now that the image is built, it gets sent to the browser. First, send out HTTP headers to
tell the browser a JPEG image is coming. */
header("Content-Type: image/jpeg");
header("Content-Disposition: inline; filename=churchsign.jpg");
/* The imagejpeg() function sends the output img to the browser. */
imagejpeg($output_img);
++++++++++++++++++++++++++++++++++++++++++++++
??
Best answer: Remove the two header lines and add the filename to the imagejpeg function:
imagejpeg($output_img,$filename);
That'll write it to a file instead of to the browser.
The imagejpeg function
posted by cillit bang at 8:46 AM on July 10, 2005
imagejpeg($output_img,$filename);
That'll write it to a file instead of to the browser.
The imagejpeg function
posted by cillit bang at 8:46 AM on July 10, 2005
Depending on what you are trying to do, you might be interested in this page. It's in Finnish but you'll be able to figure it out. Basically, pick a picture, and write what you want next to where it says "iskulause".
posted by keijo at 12:44 AM on July 11, 2005
posted by keijo at 12:44 AM on July 11, 2005
Response by poster: I stripped out the header info and used the line
imagejpeg($output_img,$newfile.jpg);
...which creates a jpg file called "jpg"!!
And it is the right image, which is exciting. If I go in and manually rename it on the server and then display it, it's fine. But I can't make it name itself "newfile.jpg".
Then I added the line
rename("jpg", "newfile.jpg");
which made everything work. Thanks all!
posted by stupidsexyFlanders at 1:45 AM on July 11, 2005
imagejpeg($output_img,$newfile.jpg);
...which creates a jpg file called "jpg"!!
And it is the right image, which is exciting. If I go in and manually rename it on the server and then display it, it's fine. But I can't make it name itself "newfile.jpg".
Then I added the line
rename("jpg", "newfile.jpg");
which made everything work. Thanks all!
posted by stupidsexyFlanders at 1:45 AM on July 11, 2005
Did you try imagejpeg($output_img,"newfile.jpg"); ?
posted by cillit bang at 6:27 AM on July 11, 2005
posted by cillit bang at 6:27 AM on July 11, 2005
Response by poster: I did try that, it threw an error, or didn't work, or something. I don't remember. But now it does work...and i just have to do the tedious work of plugging in the pixel coordinates of all the characters.
Thanks so much for your help. I'll shoot you a link when it's all done.
posted by stupidsexyFlanders at 5:22 PM on July 11, 2005
Thanks so much for your help. I'll shoot you a link when it's all done.
posted by stupidsexyFlanders at 5:22 PM on July 11, 2005
Please send me the link when you get done, I'd be interested in seeing what you do with it. I apologize for being rather grumpy about doing tech support, but I was getting way too many e-mails from people that were asking wide open questions, like "How do I make this work on my website?" (to which the answer is, "Learn PHP") rather than specific questions like this.
posted by RylandDotNet at 8:50 AM on July 12, 2005
posted by RylandDotNet at 8:50 AM on July 12, 2005
This thread is closed to new comments.
posted by stupidsexyFlanders at 8:38 AM on July 10, 2005