Jump to content

Creating images from gifs, jpegs. pngs


altemur

Recommended Posts

I have created colourfull images of characters of letters.

 

by using a form i want to create words. the words will be a image.

 

For exemple "word" is 4 letter. İnstead of 4 diffeen picture. Only one picture.

i have tried with createimagefromgif function php but i couldnt.

 

How we can do that?

Thank for advance

Link to comment
Share on other sites

Make sure PHP is compiled with GD support.  Just search google for articles containing how you would enable GD support on a PHP based server.

 

Then, you'd need to look into imagecreatefrompng or such other functions.  Also, you'll need to read up on imagettftext or imagestring, as well was imagepng/imagejpeg/imagegif...etc.

Link to comment
Share on other sites

Yes...These imagae functions WILL work.  Juct check that you have the DG lib installed first.

 

After that it is a case of opeining an image(or creating a blank one)...adding to it....returning the finishhed result.

 

Link to comment
Share on other sites

$len = strlen(strval($count));
if($len > $min_width) $width = $len;
else $width = $min_width;

if(!file_exists("$digit_dir/0.jpg")){
  die("No images in digit-dir");
}

$d0 = ImageCreateFromjpeg("$digit_dir/0.jpg");
$dx = ImageSX($d0);
$dy = ImageSY($d0);


$img = ImageCreateTrueColor($width*$dx, $dy);

ImageDestroy($d0);

$xoff = $width*$dx;
while($xoff > 0) {
  $digit = $count % 10;
  $count = $count / 10;
  $temp = ImageCreateFromjpeg("$digit_dir/$digit.jpg");
  $xoff = $xoff - $dx;
  ImageCopyResized($img,  $temp,  $xoff, 0,  0,  0,  $dx,  $dy,  $dx,  $dy);
  ImageDestroy($temp);
    }

Header("Content-type: image/jpg");

Imagejpeg($img);
ImageDestroy($img); 

Link to comment
Share on other sites

Sorry i for get to put all codes.

Here all the page

 

<?php

/********************************************************
Variables
*********************************************************/

$digit_dir = "./digits";
$file = "counter.txt";
$min_width = 5;
$lifetime = 30;
$domain = "www.offsite.be";

$use_mail = 1;
$trigger = 1000;
$your_email = "admin@offsite.be";


/********************************************************
Code --> DO NOT EDIT BELOW THIS POINT
*********************************************************/

$fp = fopen($file, "r") or die("Failed to open counter-file");
$size = filesize($file);
$count = fread($fp, $size);
fclose($fp);

if(!Isset($_COOKIE['counter'])){
  $fp = fopen($file, "w");
$count++;
fwrite($fp, $count);
fclose($fp);
  setcookie("counter","dummy",time()+60*60*24*$lifetime,$domain);
  
  if($use_mail AND ($count%$trigger==0)){
    $headers = "From: Counter <noreply@$domain>\n";
    $headers .= "X-Sender: <noreply@$domain>\n";
    $headers .= "X-Mailer: Offsite Counterscript\n";
    $headers .= "Return-Path: <noreply@$domain>\n";
    $subject = "Counter information from $domain";
    $message = "Congratulations!\n\nThe number of visitors on your site has reached $count.";
    mail($email,$subject,$message,$headers);
  }
}

$len = strlen(strval($count));
if($len > $min_width) $width = $len;
else $width = $min_width;

if(!file_exists("$digit_dir/0.jpg")){
  die("No images in digit-dir");
}

$d0 = ImageCreateFromjpeg("$digit_dir/0.jpg");
$dx = ImageSX($d0);
$dy = ImageSY($d0);


$img = ImageCreate($width*$dx, $dy);

ImageDestroy($d0);

$xoff = $width*$dx;
while($xoff > 0) {
  $digit = $count % 10;
  $count = $count / 10;
  $temp = ImageCreateFromjpeg("$digit_dir/$digit.jpg");
  $xoff = $xoff - $dx;
  ImageCopyResized($img,  $temp,  $xoff, 0,  0,  0,  $dx,  $dy,  $dx,  $dy);


  ImageDestroy($temp);
    }

Header("Content-type: image/jpg");

Imagejpeg($img);

ImageDestroy($img); 

?> 

Link to comment
Share on other sites

is there an actual image0.jpg...whats in it?  I cant se where you set the background colour.  havent time to test...but those are the 2 things i'd check.

 

Will

 

the images in

 

$digit_dir = "./digits";

 

and i do not know where i can set the background color

Link to comment
Share on other sites

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.