|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
||||
|
||||
|
Help with GD-functions in PHP
Hi!
I've searched for a long time on the net, but I didn't exactly found where I was looking for. The purpose of my function is to resize an image. That's not the hardest part. But I want the function to automatically change the longest side of the pic. I.E. User uploads image 1024x768, function resizes it to 800x600 User uploads image 768x1024, function resizes it to 600x800 Is there a way to check which side is the longest? |
|
#2
|
||||
|
||||
|
There are functions for getting the dimensions of an image (I forget what the precise function is). The quick and dirty way to do this is to get these dimensions and test for which one is bigger. If the x axis is bigger, resize to 800x600; else resize to 600x800.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
||||
|
||||
|
Could you provide some code for me? I never used GD before...
[edit] I figured it out. I now use getimagesize(). But it's not perfect. Suggestions are still welcome!!! [/edit]
__________________
Work to live, don't live to work |
|
#4
|
||||
|
||||
|
Now I'm trying to add text on a image. I use the function Imagestring() but it doesn't seem to work... Any GD-guru's here who knows how to do this?
I succesfully resized images now and I want a copyright notice on the image in the lower-rightcorner. I've seen a lot of sites using this, but I just don't seem to find the right function... Please help me!! |
|
#5
|
||||
|
||||
|
Perhaps this tutorial will help ya:
http://www.phpfreaks.com/tutorials/105/1.php Here's a quick example of display text as an image (taken from the tutorial mentioned above): PHP Code:
|
|
#6
|
||||
|
||||
|
Thnx for the tip, but...
I don't want to create a new canvas to put my text on... I want to insert my text on an excisting image. I don't know if it's possible, but I want to make it cross-filetype. So that it will work on GIF, JPEG, PNG etc. |
|
#7
|
||||
|
||||
|
Maybe this code snippet will help. I've pulled it out of the scope of a class, so you'll need to read around all the $thises. Basically, to add text to an existing image, you have to create a bounding box. In this code, I'm also doing a check to make sure the text will fit on the image I'm writing it to (the if block) and dying if it won't. After you've created your bounding box, you allocate a color, and then you just add your text to the image, passing the appropriate coordinates, widths, etc., as documented at php.net. Hope this'll get you started.
PHP Code:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Help with GD-functions in PHP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|