TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-13-2008, 05:42 AM   #1 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default Gd images

How would I get images to stay in the imagecreatetruecolor, so I don't have to see the black?
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 03-13-2008, 10:00 AM   #2 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Please provide a less obscure description of your problem...
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 03-13-2008, 11:07 AM   #3 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by xenon View Post
Please provide a less obscure description of your problem...
How would I have the width and height set to where it fits the image color, using imagecreatetruecolor, the background is black, and no matter how much I try when using imagecopyresampled, it will show the background imagecreatetruecolor
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 03-13-2008, 11:49 AM   #4 (permalink)
The Addict
Upcoming Programmer Top Contributor 
 
Rendair's Avatar
 
Join Date: Nov 2007
Location: UK
Posts: 319
Thanks: 18
Rendair is on a distinguished road
Default

imagecreatetruecolor() returns an image identifier representing a black image of the specified size.

in order to change the background colour you can use the following script.

PHP Code:
$bg imagecolorallocate($im2331491); 
Place right after the imagecreatetruecolor()
__________________
www.jooney.co.uk - the online portfolio
Send a message via MSN to Rendair
Rendair is offline  
Reply With Quote
Old 03-13-2008, 03:06 PM   #5 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Rendair View Post
imagecreatetruecolor() returns an image identifier representing a black image of the specified size.

in order to change the background colour you can use the following script.

PHP Code:
$bg imagecolorallocate($im2331491); 
Place right after the imagecreatetruecolor()
I know that, but you don't get what Im saying.. I mean Im getting the image from a database. And I hate black backgrounds showing up, ya know, so yeah.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 03-13-2008, 03:11 PM   #6 (permalink)
Nor
The Addict
 
Join Date: Nov 2007
Posts: 282
Thanks: 61
Nor is on a distinguished road
Default

I'm guessing your trying to do transparency images?
__________________
PHP/XHTML Freelancer:
Cleanscript.com v3 - Programming starting at just $5 act now!
Nor is offline  
Reply With Quote
Old 03-13-2008, 04:41 PM   #7 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Nor View Post
I'm guessing your trying to do transparency images?
imagesavealpha, yes yes, I know but.. Hmm? Would that work?
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 03-13-2008, 05:10 PM   #8 (permalink)
The Addict
Upcoming Programmer Top Contributor 
 
Rendair's Avatar
 
Join Date: Nov 2007
Location: UK
Posts: 319
Thanks: 18
Rendair is on a distinguished road
Default

Quote:
Originally Posted by Orc View Post
I know that, but you don't get what Im saying.. I mean Im getting the image from a database. And I hate black backgrounds showing up, ya know, so yeah.
You dont need to be rude about it i am sorry if you are not very clear on what exactly you want
__________________
www.jooney.co.uk - the online portfolio
Send a message via MSN to Rendair
Rendair is offline  
Reply With Quote
Old 03-13-2008, 05:14 PM   #9 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

How about giving everyone a visual example (starting images [yes, from the database], resulting images [with black backgrounds] and the appropriate code you're using [or all of it])?
Salathe is offline  
Reply With Quote
Old 03-13-2008, 05:49 PM   #10 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Sorry Rendair, hang on, lemme try to make it better..


Say that the black was the imagecreatetruecolor width and height, when cropping images, it does this to me, when just resizing it, its fix, how would I get this? Say, to a certain point of which the image width ends, I dont want imagecreatetruecolor width's black, I would it to be stopped, how would I do this?

Or shall I delete this thread, and figure it out myself? I don't know what else to say. :/
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 03-13-2008, 11:21 PM   #11 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Well, I'd suggest you calculate the thumbnail dimensions BEFORE creating the virtual image to store the thumb into. Then, you wouldn't have problems with imagecopyresampled. If the image has some transparent pixels around it, run a function on the image to see where is the image ending (imagecolorat).
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 03-13-2008, 11:23 PM   #12 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by xenon View Post
Well, I'd suggest you calculate the thumbnail dimensions BEFORE creating the virtual image to store the thumb into. Then, you wouldn't have problems with imagecopyresampled. If the image has some transparent pixels around it, run a function on the image to see where is the image ending (imagecolorat).
I have done that. I took the width and height and list() them and then put them in the database like so 000x000, then I went and explode() the x and made $foo[0] and $foo[1] thus gave me the width and height.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 03-14-2008, 03:48 AM   #13 (permalink)
Nor
The Addict
 
Join Date: Nov 2007
Posts: 282
Thanks: 61
Nor is on a distinguished road
Default

Mind posting your code :D & db table example
__________________
PHP/XHTML Freelancer:
Cleanscript.com v3 - Programming starting at just $5 act now!
Nor is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 10:47 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design