note 96333 added to function.imagerotate
| From: | ckelleyatca-cycleworksdotcom at osu1 dot php dot net | Date: | Sat, 20 Feb 2010 22:59:23 +0000 |
| Subject: | note 96333 added to function.imagerotate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-166221@lists.php.net to get a copy of this message | ||
Note, of the rotate functions below, only beau's worked for me. Not sure if it is because of my
source image, but upon rotating, the background became blue.
The code snippet below is what I used to prepare UPS shipping labels. The UPS xml api will return a
base64 encoded gif, but it is sideways, so as to print on the top half of a 8.5x11
"letter" page. We are saving it in a database and sending it to a label printer, so needed
it rotated...
The other code further down didn't make the background blue, however it did make the image
leave the canvas by about 50%. Additionally, the imagecolorallocate() function has an example
describing how to set the background color. That didn't work for me. Even though the blue BG is
#0000ff, using that code didn't work, I had to use the transparent trick below.
The GD image functions may be in their infancy, however are a great reminder to me how powerful php
is! Also, ubuntu apache users will need to apt-get install php5-gd to get the gd functions.
<?php
$image=imagecreatefromgif(
'data://text/plain;base64,'.$this->shipmentLabelGraphicImage );
$image=$this->rotateImage($image, 90); // Note: rotateImage turns our background to blue!
$blue = imagecolorallocate($image, 0, 0, 255);
imagecolortransparent($image, $blue); // make blue transparent, so image isn't goofy
imagepng($image,$this->shipmentTrackingNumber.".png");
echo '<P><img
src="'.$this->shipmentTrackingNumber.'.png"></P>';
imagedestroy($image);
?>
----
Server IP: 82.177.164.100
Probable Submitter: 69.224.120.77
----
Manual Page -- http://www.php.net/manual/en/function.imagerotate.php
Edit -- https://master.php.net/note/edit/96333
Del: integrated -- https://master.php.net/note/delete/96333/integrated
Del: useless -- https://master.php.net/note/delete/96333/useless
Del: bad code -- https://master.php.net/note/delete/96333/bad+code
Del: spam -- https://master.php.net/note/delete/96333/spam
Del: non-english -- https://master.php.net/note/delete/96333/non-english
Del: in docs -- https://master.php.net/note/delete/96333/in+docs
Del: other reasons-- https://master.php.net/note/delete/96333
Reject -- https://master.php.net/note/reject/96333
Search -- https://master.php.net/manage/user-notes.php