ireallylikepie
-
Posts
13 -
Joined
-
Last visited
Posts posted by ireallylikepie
-
-
Ahh nevermind I've fixed it!(:
Was missing the &
Thank you so so so much for all your help!
I truly appreciate it.
-
I can't seem to get the variables from one php file to the other. :/
Should I be using include or $_GET ?
-
No, I created a textbox in which the user could input their desired background color. On mainpage.php, $back = $_GET['backgroundinput'] and then I print <body style='background-color:$back;'></body>
-
Pass it in the querystring like the image name and angle
Ahhh! Am I doing something wrong --- now no image shows up!!
<?php $im = imagecreatefrompng($_GET['i']); include 'mainpage.php'; $bg = $back; $im = imagerotate($im, $_GET['r'], $bg); header('content-type: image/png'); imagecolortransparent($im, $bg); imagealphablending( $im, false ); imagesavealpha( $im, true ); imagepng($im); imagedestroy($im); ?>
-
Yes, however, I made it so that the user could choose the background color. Is it possible to use a variable in imagecolorallocate?
-
Yes. I think I know what the problem is though.
I added these two lines as well, to keep the original image background transparent.
imagealphablending( $im, false ); imagesavealpha( $im, true );
When I remove those two lines, the image background isn't transparent, but the pink corners are gone.
-
I must have something else wrong in my code then, because i see this:
(Turquoise is the current background of the site)
-
try this for rotate.php
<?php $im = imagecreatefrompng($_GET['i']); $bg = imagecolorallocate($im, 0xFF, 0x00, 0xFF); $im = imagerotate($im, $_GET['r'], $bg); imagecolortransparent($im, $bg); header('content-type: image/png'); imagepng($im); imagedestroy($im); ?>
Hmm... now it's pink?
-
I've tried :
imagesavealpha( $im, true );
and changing the code you've provided with:
$im = imagerotate($im, $_GET['d'], 0);
but it still doesn't seem to work. D:
-
Alternative approach
main page
<?php$degree = 45;$image = 'images/logo.PNG';echo "<img src='rotate.php?i=$image&r=$degree' />"?>
rotate.php<?php $im = imagecreatefrompng($_GET['i']); $bg = imagecolorallocate($im, 0xFF, 0xFF, 0xFF); $im = imagerotate($im, $_GET['r'], $bg); header('content-type: image/png'); imagepng($im); imagedestroy($im);?>
The rotating worked!
However, my images were basically all in black with a transparent background, but for some reason the rotating cause there to be a white background for each image. I'm guessing that this is from the image colorallocate... so is there someway I can make do without it ?
No, I would like each image to rotate by a randomly generated degree. So you're saying I could use a <div style = ""></div> ?No, you can't put variables in CSS. Not without running the file as a PHP script.
Are you rotating all the images by the same amount? Then I would put the CSS in a <style> in the <head>. But the code you posted has a different amount for each image, in which case I'd say to use inline CSS for each. Blasphemy, I know.
-
here is an example of rotating images.
Imports System.IO
Imports System.Drawing.Printing
Imports RasterEdge.Imaging
Imports RasterEdge.Imaging.Processing
Dim Image As New RasterEdgeImaging()
Public Sub RotateImage()
If True Then
Dim LoadImage As New Bitmap("C:\\1.bmp")
Dim rotate As Graphics = Graphics.FromImage(LoadImage)
rotate.TranslateTransform(CType(bmp.Width, Single) / 2, CType(bmp.Height, Single) / 2)
rotate.RotateTransform(rotationAngle)
rotate.TranslateTransform(-CType(bmp.Width, Single) / 2, -CType(bmp.Height, Single) / 2)
rotate.InterpolationMode = InterpolationMode.HighQualityBicubic
rotate.DrawImage(img, New Point(0, 0))
rotate.Dispose()
Return LoadImage()
End If
End Sub
Hmmm, I'm not sure what language this is, and how I would put it into my php loop.
It will be a different amount. The problem is you're trying to put variables inside a single-quoted string. That won't work. Either use double-quotes
echo "<img src='blabla.gif' width='$num' height='$num'>";
or something else entirely.CSS 3 is a very easy way to rotate an image but it requires browsers that support that. Many, perhaps most, do. That an option? Otherwise you'll have to rotate the image yourself (I mean with code, of course)...
Yay! It works now. (:
Hmm, but if I want each picture to rotate a different number of degrees, wouldn't I have to put it into the php loop? Could I use:
echo file_get_contents('picture.css');
And then in the separate css file would I put in:
.image-box img { transform: rotate($degree); -moz-transform: rotate($degree); -webkit-transform: rotate($degree); }
I'm not sure if you can put in variables in CSS, or how to put something in php under a class. :/
-
Hi,
New coder here! I'm making a php If loop that will post my image a set number of times (depending on user input in a text box), and I have that all figured out. However, I can't figure out how to rotate the image a random amount of degrees and have a random width/height for each image. Will rand generate new numbers for each time the image is echo-ed, or will it give the same number for all images?
This is what I have:
<?php
function pic($picture) {
$degree = rand(0,360)
$num = rand(50,250)
$total = 0;while ($total < $picture){echo '<img src=blabla.gif width="$num" height="$num">';$total = $total + 1;}}$picture = $_GET['input'];$a = pic($picture);}?>
Thanks in advance!
Random Width/Height and Random Rotation
in PHP Coding Help
Posted
Yeah, haha, realized that shortly after replying to the post. (:
Thanks again !