Jump to content
php.lv forumi

Problēma ar ģenerētu bildi no teksta ar GD bibliotēku


L4URO
 Share

Recommended Posts

(skatīt bildi pielikumā)

 

tā tad es veiksmīgi ģenerēju bildi no teksta,tad ,uzspiežot labo peles taustiņu man ir iespēja "saglabāt attēlu kā " ,bet ,kad uzspiežu man piedāvā saglabāt nevis kā jpeg failu,bet kā php skriptu.

 

Kods,lai uztaisītu bildi (sesija ir tāpēc,ka ienesu saturu no cita faila) :

 

 


<?php
session_start();
header('Content-type: image/jpeg');
 
$email = $_SESSION['varname'];
$email_lenght= strlen ($email);
 
$font_size=4;
 
 
$image_height = ImageFontHeight ($font_size);
$image_width = ImageFontWidth ($font_size) * $email_lenght;
 
$image = imagecreate($image_width, $image_height);
 
 
imagecolorallocate($image, 255, 255, 255);
$font_color = imagecolorallocate($image, 0, 0, 0);
 
imagestring($image, $font_size, 0, 0, $email, $font_color);
 
imagejpeg($image);
 
imagedestroy($image);
 
?>

post-9782-0-25343500-1384897849_thumb.jpg

Edited by aaxc
Link to comment
Share on other sites

Ko satur tas .php? Ne jau tak īsto kodu, ne? :D

ja es pats uzlieku .jpg tipu tad ieseivoja kaa bilde bet kad saglabaa kaa php skriptu tad tajaa ieksa ir

 

яШяа JFIF    яю >CREATOR: gd-jpeg v1.0 (using IJG JPEG v90), default quality
яЫ C
 
$.' ",#(7),01444'9=82<.342яЫ C
 
2!!222222222222222222222яА P" яД          
я µ  } !1AQa"2Ѓ‘Ў#B±БRСр$3br‚
&(*456789:DEFGHIJSTUWXYZcdefghxyzѓ„…†‡€‰Љ’“”•–—™љўЈ   
 µ  !1Aaq"2ЃB‘Ў±Б#3RрbrС
 
sitadu baigi daudz :D
Edited by L4URO
Link to comment
Share on other sites

Vari pamēģināt šādu headeri pielikt...

header('Content-Disposition: attachment; filename="blabla.jpg"');

 

nezinu gan, vai strādās :)

strada,man ir ta ka to uzgenereto bildi atver jauna cilnee un tad es gribeju lai cilvekam ir iespeja ieseivot

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
 Share

×
×
  • Create New...