473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem with transparent background with imagerotate

5
Hey everyone how are you all doing?

I am trying to use the imagerotate GD function to place an image on top of another image at an angle. Obviously when it rotates an image it creates a rectangular image big enough to fit the angled image inside with the background colour of this defined in the third arg of imagerotate. The problem i'm having is i want to make this background colour transparent so when i copy it on top of my existing big image the image appears properly at an angle and this background doesn't cover up the pictures it's being placed on.

I have the following code:

$u2 = imagecreatefromgif($user2);
$rotate = imagerotate($u2, -5, 7);
//$rotatecol=imagecolorallocate($rotate, 0, 0, 0);
//imagecolortransparent($rotate, 7);
//imagealphablending($rotate, true);
//imagesavealpha($rotate, true);

$rwidth=imagesx($rotate);
$rheight=imagesy($rotate);
imagecopymerge($im1,$rotate,273,71,0,0,$rwidth,$rh eight,100);
imagejpeg($im1,$filepath,100);

This all works perfectly, except it uses (in this case) grey (from the final value in imagerotate) as the background to the rotated image and then you can see the grey backing on the final image. I cannot for the life of me work out how to set this as transparent instead of grey, both u2 and im1 are truecolor images and i tried using a combination of imagecolortransparent/ imagealphablending/ imagesavealpha as you can see above, but to no avail.

I would so appreciate any pointers anyone could give me as to how to make this work, as it's driving me crazy and i know i'm not really understanding the logic of it, which i think is why ican't work out how to do it, no matter how much of the manual i read!!!

Thanks so much everyone,

Dave
Dec 19 '07 #1
1 4008
MarkoKlacar
296 Expert 100+
Hi Dave,

haven't tryed this my self, it can be related to the fact that you create a gif image.
My experiece tells me that images that contain transparent areas don't, in PHP, always work out like you want them to.

I don't have a silverbullet for your problem, what I would try is use a PNG image instead of GIF.

I wish you luck!
Dec 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: AMcD | last post by:
Hi! Here's a piece of code: <?php Header('Content-type: image/png');
0
by: Martin | last post by:
Does the "imagerotate" function in PHP5 work correctly or am I doing something wrong? I'm using the code shown below to generate a simple rectangle and then to rotate it a specific number of...
7
by: Ed Mullen | last post by:
The http://jigsaw.w3.org/ validator does not seem to like "transparent" as a background color and gives this error: Line : 5 (Level : 1) You have no background-color with your color : #logo_1 ...
1
by: Efkas | last post by:
My application have some level : 1. MyButton class with Label inheritance 2. MyComponent as User Control loading and positionning some of MyButtons 3. MyApp loading and positionning MyComponent ...
5
by: althafexcel | last post by:
hi everyone Im trying to include an external js in my aspx page under the head tag, it doesn't load or it displays an object expected error whenver the function from the .js is called. Actually...
4
by: comp.lang.php | last post by:
Recap: Using imagerotate within PHP 4.3.9 - PHP 5.2.0 for both XP and Linux, all using GD2 If you rotate an image 180 degrees, all is fine If you rotate an image 0 degrees and < 180...
0
by: sjickells | last post by:
Hi I am having a problem using asp:TextBox's in a transparent table. I have a background image on the page and a table in the middle of the page. I have set the background colour of the table...
1
by: newcomer2k | last post by:
Hi experts, I used 2 divs (side-bar and main-copy) and tried to line them side by side. For the most part this works fine. Both divs appear at the same y- value on the screen. However, as I...
2
by: swethak | last post by:
Hi, I am getting the problem the problem with google map in Internet Explorer. This map worked fine in mozilla . When i opened the same map in Internet Explorer i am getting the error...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.