Hi All:
I'm posting again, with more details about the imaging issues I am
having with 5.6.13. I have a routine that takes an image from a
database, reformats it, watermarks it, and adds a white bar with some
text on the bottom of it. Everything was working very well until I moved
the script on to a different server.
The PHP version on the server that is not having issues is:
PHP 5.5.14 (cli) (built: Dec 30 2014 15:38:33)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
The PHP version on the new server is:
PHP 5.6.13 (cli) (built: Sep 8 2015 23:01:10)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
---
$file_wmk = '/var/tmp/' . $ticket_data[1] . '.jpg';
$file_nowmk = '/var/tmp/' . $ticket_data[1] . '-nowmk.jpg';
$wmkfile = '/root/aarf_logo.jpg';
$wmkimg = imagecreatefromjpeg($wmkfile);
$image_data = mysqli_fetch_array($article_images);
$tempimg = imagecreatefromstring ($image_data[7]);
$width = imagesx($tempimg);
$height = imagesy($tempimg);
$aspect_ratio = $height/$width;
imagejpeg($tempimg,$file_nowmk);
/*
Correct orientation issues for files with EXIF data /*
if
(strpos($image_data[4],"jpeg") > 0) {
$exif_data = substr($image_data[7],0,64000);
$exif_file = '/var/tmp/tmp_exif.jpg';
file_put_contents($exif_file, $exif_data);
$exif_array = exif_read_data ($exif_file);
if ($exif_array['Orientation'] == 8) {
$tempimg = imagerotate($tempimg,90,0);
}
if ($exif_array['Orientation'] == 3) {
$tempimg = imagerotate($tempimg,180,0);
}
if ($exif_array['Orientation'] == 6) {
$tempimg = imagerotate($tempimg,-90,0);
}
}
/*
Create new blank water mark image */
$newwmk =
imagecreatetruecolor(round(imagesx($tempimg)/3),round(imagesx($tempimg)/3));
imagealphablending($wmkimg,true);
/*
Resize watermark to 1/3rd the size of the source image /*
imagecopyresampled
($newwmk,$wmkimg,0,0,0,0,round(imagesx($tempimg)/3),round(imagesx($tempimg)/3),imagesx($wmkimg),imagesy($wmkimg))
$x_coord = imagesx($tempimg) - imagesx($newwmk);
$y_coord = imagesy($tempimg) - imagesy($newwmk);
/*
Merge watermark into source image */
imagecopymerge($tempimg, $newwmk, $x_coord, $y_coord, 0, 0,
imagesx($newwmk),imagesy($newwmk), 20);
/*
Create new blank image for the text box along the bottom.
$textimg = imagecreatetruecolor (640,round((640 * $aspect_ratio) + 30));
$white = imagecolorallocate($textimg, 255, 255, 255);
$grey = imagecolorallocate($textimg, 128, 128, 128);
$black = imagecolorallocate($textimg, 0, 0, 0);
/* Copy
source image into new blank image. */
imagecopyresampled ($textimg,$tempimg,0,0,0,0,640,round(640 *
$aspect_ratio),$width,$height);
/*
White rectangle for text */
imagefilledrectangle ($textimg,0,round(640 *
$aspect_ratio),640,round(640 * $aspect_ratio) + 30,$white);
/* Put
text in if condition exists, otherwise leave it blank */
if
($namestart >= 1) {
$imagetext = $petname . " since " . $datelost;
$textarea = imagettfbbox
(20,0,'/usr/share/fonts/TTF/OpenSans-Bold.ttf',$imagetext);
imagettftext ($textimg,20,0,(320) - ($textarea[4]/2),round((640 *
$aspect_ratio) + 28),$black,'/usr/share/fonts/TTF/OpenSans-B
}
imagejpeg($textimg,$file_wmk);
...The end result on the old server (or using imagescale on the new
server) is:
http://www.aarf.ca/files/2015092410000017-imgscale.jpg
Using imagecopyreampled on the new server:
http://www.aarf.ca/files/2015092410000017-resamp.jpg
I am still trying to figure out why the colours when using
imagecopyresampled on a newer version of PHP look so messed up.
Thoughts, ideas, and suggestions would be very much appreciated.
Thanks,
Richard.
-- Alberni Valley IT Services
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php