php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22756 ImageJPEG
Submitted: 2003-03-17 21:42 UTC Modified: 2003-03-24 04:19 UTC
From: boy at 7935 dot com Assigned:
Status: Not a bug Package: GD related
PHP Version: 4.3.1 OS: WIN2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: boy at 7935 dot com
New email:
PHP Version: OS:

 

 [2003-03-17 21:42 UTC] boy at 7935 dot com
I write a script to genreate rand string and image it with imagejpeg, the picture(0.jpg-9.jpg)'s color is red and the picture(a.jpg-f.jpg)'s color is blue, but when I test it I found sometime the color of new image will make some mistake, such as red digital picture became white-blue and the blue digital picture became white-red.

Setting: Apache2.0.44+PHP4.3.1
you can see the demo at http://www.blists.com/image.html
please refresh it some times.
thank you!



<?php
session_start();
$DIR_SET['vcode'] = "http://www.blists.com/images/vcode";
function Vcode($num = "",$type = "") {
 $string = array(
  'digit'=>'0123456789',
  'alpha'=>'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
  'mixed'=>'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
  'shortmixed'=>'01234567ABCDEF'
 );
 $str   = "";
 
 if ($num == "")  $num = 4;
 if ($type == "") $type = "mixed"; 
 
 for ($i=0;$i<$num;$i++) {  
   $offset = rand(0,strlen($string[$type])-1);
   $str .= @substr($string[$type],$offset,1);
  }
 return $str;
}




$str = Vcode(5,"shortmixed");
$_SESSION['vcode'] = md5($str);
header("Content-Type:image/jpeg");

$src_im = imagecreate(100,18);
$x = 0;
for ($i=0;$i<strlen($str);$i++) {
 $image = substr($str,$i,1);
 $dst_im = imagecreatefromjpeg($DIR_SET['vcode']."/".$image.".jpg");
 imagecopymerge($src_im,$dst_im,$x,0,0,0,20,18,100);
 $x+=20;
}
imagejpeg($src_im);

?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-19 11:52 UTC] pollita@php.net
The demonstration link you provided does not work (Indeed I get not so much as a ping response from that host).  Judging from your script my guess is that it's a palette issue which can be solved by using imagecreatetruecolor() rather than imagecreate().
 [2003-03-19 20:17 UTC] freish at 55it dot com
thank you, I solved this problem with imagecreatetruecolor() with your help. I need take more time to read the manuals before I submit a bug report, I think.
 [2003-03-24 04:19 UTC] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 14:04:04 2025 UTC