Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-30-2012, 02:34 PM   PM User | #16
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by angelali View Post
Facepalm to myself. I need a weed I think. My head is too heavy to understand thing. So, if I copy and paste the script in another page then INCLUDE the page to the one, will it work?
Nope, you can never include it in. It is an image, you can only use the output as an image such as in a <img> tag.
Fou-Lu is offline   Reply With Quote
Old 11-30-2012, 02:36 PM   PM User | #17
angelali
Regular Coder

 
Join Date: Sep 2011
Posts: 310
Thanks: 23
Thanked 0 Times in 0 Posts
angelali is an unknown quantity at this point
Well forget this crap! Im fed up of this!
angelali is offline   Reply With Quote
Old 11-30-2012, 02:41 PM   PM User | #18
Thyrosis
New Coder

 
Join Date: Nov 2012
Posts: 72
Thanks: 4
Thanked 11 Times in 11 Posts
Thyrosis is on a distinguished road
Simple solution is to have your code save the image to a temporary name and load that into the page. That way you skip the header issue.
Thyrosis is offline   Reply With Quote
Old 11-30-2012, 02:42 PM   PM User | #19
angelali
Regular Coder

 
Join Date: Sep 2011
Posts: 310
Thanks: 23
Thanked 0 Times in 0 Posts
angelali is an unknown quantity at this point
Or perhaps, it has nothing to do with the header but to the src of the image. I tries ob_start, flush, end flush etc, but in vain. In fact, all other websites I saw, they are doing the same as me and they are not getting errors. Do you think it has something to do with the src of the img tag?
angelali is offline   Reply With Quote
Old 11-30-2012, 02:46 PM   PM User | #20
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by angelali View Post
Or perhaps, it has nothing to do with the header but to the src of the image. I tries ob_start, flush, end flush etc, but in vain. In fact, all other websites I saw, they are doing the same as me and they are not getting errors. Do you think it has something to do with the src of the img tag?
The current source of your image tag is an .jpg indicating it is not this script. That image is already corrupt. You can point it at your script if you want, but if you are doing something like a watermark, I'd suggest it is much more efficient to write once and store the image than constantly writing the watermark. GD has a lot of overhead in it, so use it sparingly. If the data is supposed to be dyanmic (like, a barcode) then it makes sense to use the GD to build that at runtime.
Fou-Lu is offline   Reply With Quote
Old 11-30-2012, 02:49 PM   PM User | #21
angelali
Regular Coder

 
Join Date: Sep 2011
Posts: 310
Thanks: 23
Thanked 0 Times in 0 Posts
angelali is an unknown quantity at this point
This sucks. Wait, suppose I have an image on the page. I have a textbox below, and a user write some texts and press OK, the forms goes to another page, and output the text on the image which was the same on the page the user wrote the text, we cannot?

Guys, can you help me on a last thing? Its not about issue but want to know something. Its better i ask to avoid losing time to try it.

Last edited by Inigoesdr; 12-01-2012 at 12:17 AM..
angelali is offline   Reply With Quote
Old 11-30-2012, 04:59 PM   PM User | #22
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Give us a link to your image so we can see it.

We can give you an example of writing text on it.



.

Last edited by mlseim; 11-30-2012 at 05:02 PM..
mlseim is offline   Reply With Quote
Old 11-30-2012, 05:23 PM   PM User | #23
angelali
Regular Coder

 
Join Date: Sep 2011
Posts: 310
Thanks: 23
Thanked 0 Times in 0 Posts
angelali is an unknown quantity at this point
Hi, sorry, but I abandoned the project. Thank you anyway.
angelali is offline   Reply With Quote
Old 11-30-2012, 10:23 PM   PM User | #24
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Nooo ... don't abandoned it.

At least post the image somewhere and let us play with it.
Describe what text needs to be added (font ,size and color).
It's easy to show a working example.
mlseim is offline   Reply With Quote
Old 12-01-2012, 05:27 AM   PM User | #25
angelali
Regular Coder

 
Join Date: Sep 2011
Posts: 310
Thanks: 23
Thanked 0 Times in 0 Posts
angelali is an unknown quantity at this point
I will try a last time. Hope it will work.
angelali is offline   Reply With Quote
Old 12-01-2012, 03:10 PM   PM User | #26
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Please post a link to the photo or image you have, and describe what
needs to be put "embedded" into the photo ... text, font, color, etc.
mlseim is offline   Reply With Quote
Old 12-02-2012, 10:31 AM   PM User | #27
angelali
Regular Coder

 
Join Date: Sep 2011
Posts: 310
Thanks: 23
Thanked 0 Times in 0 Posts
angelali is an unknown quantity at this point
I have tried y maximum to figure out how these websites are writing texts online on images but in vain. I thought it was HTML5 Canvas, but unfortunately, you cannot do that as if you want to edit a text, you have to reset the whole canvas. I switched to PHP GD, again the same thing, there is no multiline functionality either.

Here is a little example what I want to do:

http://www.someecards.com/usercards/create
angelali is offline   Reply With Quote
Old 12-02-2012, 03:18 PM   PM User | #28
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Their program is much more elaborate than my example.

But this is a simple example:
http://www.catpin.com/card_sample/

Since you won't give us an image to use, I'll make one up ...

PHP Code:
<?php 
// Card Sample - Generator 

// Get form variables
$gfirst $_POST['gfirst'];
$gmiddle $_POST['gmiddle']; 
$glast $_POST['glast']; 
$bfirst $_POST['bfirst']; 
$bmiddle $_POST['bmiddle']; 
$blast $_POST['blast']; 

// Generate Image & set width 
$image imagecreatefromjpeg("card1.jpg"); 
$imageWidth imagesx($image); 

// Generate Bride 
$color imagecolorallocate($image1796366); 
$font "mlsjn.ttf"
$fontSize "24";

// The hardest part will be to get the actual width of the text (in pixels).
// This will be used to determine the position and margins.
// In this example, I am not doing any math ... just using fixed positions.
// But this is the way to get the text width 
// $b1 = imagettfbbox($fontSize, 0, $font, $bfirst);
// Then, instead of 95, you would do some math using $b1.
 
imagettftext($image$fontSize095130$color$font$bfirst); 
imagettftext($image$fontSize095165$color$font$bmiddle);
imagettftext($image$fontSize095200$color$font$blast);

// Generate Groom 
$color imagecolorallocate($image1796366); 
$font "mlsjn.ttf"
$fontSize "24"
//$ret = imagettfbbox($fontSize, 0, $font, $month); 
imagettftext($image$fontSize0375130$color$font$gfirst); 
imagettftext($image$fontSize0375165$color$font$gmiddle);
imagettftext($image$fontSize0375200$color$font$glast);

// Output & Free Memory 
header("Content-type: image/jpeg"); 
imagejpeg($image); 
imagedestroy($image); 
?>
mlseim is offline   Reply With Quote
Old 12-02-2012, 03:41 PM   PM User | #29
angelali
Regular Coder

 
Join Date: Sep 2011
Posts: 310
Thanks: 23
Thanked 0 Times in 0 Posts
angelali is an unknown quantity at this point
I did a card, but I abandoned when the multiline function does not work. Moreover, when you edit a textbox, or even remove a value, then click submit, it does not update the card. I mean on your example. This is why I lost courage earlier.
angelali is offline   Reply With Quote
Old 12-02-2012, 05:16 PM   PM User | #30
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
OK ...
I would guess there are scripts, like the one you mention earlier, that you can purchase.
mlseim is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:04 AM.


Advertisement
Log in to turn off these ads.