How to include an image inside another image in PHP? I want to do it like in twitterbackgrounds.com personalized backgroud. there is one main image and we can upload four personal images after that it will show as watermark of the main image.
I never used GD by myself, but look at the example in the manual, wich is about "Using imagecopymerge() to create a translucent watermark".
Well, there are several possibilies to do that. The one that pops into my mind is to use a php page where you can upload all files needed for this. After submission you can use imagemagick to create the new image with watermarks and display it on another webpage or store it to a database.
Here is a good tutorial on how to use imagemagick to create the watermarks in another image.
you may use imagemagick as commandline command from php or use it as a server application on an own server
phpThumb has a watermark feature, if you're looking for something full-featured and ready-made..
Related
I have a question about saving text/strings as images in PHP. Since I want to protect data on my site, I want to convert text and save it as image files in a folder on a server (before displaying it). Is there a way to do it, or maybe a better solution? Thanks in advance
If you wish to convert Text/String into image, you can try ImageMagick or GD.
Detail about ImageMagick (Imagick extension) is available at http://php.net/manual/en/book.imagick.php)
Detail about GD at http://php.net/manual/en/book.image.php
getimagettftext() function from GD can be useful, see detail at http://php.net/manual/en/function.imagettftext.php
Imagick::annotateImage() function from Imagick can be useful, see detail at http://php.net/manual/en/function.imagettftext.php
If you want to save text as an image, not overlay it on another image, then you should use label: or caption: or tango: in ImageMagick and not annotate.
See http://www.imagemagick.org/Usage/text/. Then find the equivalent command in Imagick. For example, http://us3.php.net/manual/en/imagick.labelimage.php
You can use the equivalent of -annnotate, but then you have to create an background image onto which to write the text.
The advantage of label: for example is that it creates an image automatically.
I have an image of NxN size and an image of MxM, with N>M. I want to place the second on top of the first, but I want to do it on a specific pixel e.g.(10,15)
I installed imagemagick and start playing with it cli (planning to try with php later), but I could not find if there is something that I could use for this purpose or if it is possible by combining some commands.
So my question(s):
Is something like this possible with imagemagick?
If yes, how could I achieve it in command line imagemagick?
If yes, how could I achieve it with imagemagick in php?
Expanding on my comment, I think php gd would be a good fit for this. PHP gd is better integrated into php and works better in my opinion. I use it for a host of things (resizing thumbnails most notably). Your question seems very similar to placing a watermark on an image, ie one image is place on top of another and it is exported as a single raster image. Here's a quick example for creating this watermark:
http://www.sitepoint.com/watermark-images-php/
This example exports it directly to the browser, but it can be easily modified to save the image locally to your file system. Enjoy!
I want to add a small functionality to my site wherein a user can upload his pic and then on selecting a specific color(basically on clicking something) a splash effect of that color gets added to that image.
The user should then get an option to save that image.
Is it possible using the php GD library? Any helpful comments are welcome.
Edit: What if i create the images for these effects? how can i overlay them on the user's pic and then offer the complete image as a download?
The simplest way to achieve this is to create the effect in another image and just use PHPs GDlib to copy that image on the image uploaded by the user and change the color.
You can use imagecopy or imagecopyresized or imagecopyresampled. Depending on the image you are using you could for example use imagecolorset to change the color of the effect.
The full list of PHPs image functions is in the PHP manual.
Use of the GD library might work here, but this is something that ImageMagick was built for. I'd look into using that, as it's almost as ubiquitous.
Just use the original image as a background image, and add on top of that a full sized fill of a colour at a reduced opacity.
http://us2.php.net/manual/en/function.imagecolorallocatealpha.php
I'm creating a web app that allows users to specify an image url to display an image along with their submission.
To avoid some potentially large images and odd sizes, i'd like to use PHP to limit/resize the image before it gets output to the browser (I know i could use max-width in CSS but this is unnecessary downloading)
Is this possible?
PHP has a library named GD. It's fairly easy to check the size of an image with the getimagesize() function.
You can find the complete code for it with 2 module/extensions: http://www.fliquidstudios.com/2009/05/07/resizing-images-in-php-with-gd-and-imagick/
a comparison of them can be found here: http://dreamfall.blogspot.com/2008/02/php-benchmarks-gd-vs-imagemagick.html which may be of use if you want optimize features.
i work in lamp environment .
i search script that know to take a image , that user upload to my site.
and make from this image , new image that contain the real image with small stamp on the top corner.
thanks
your best bet would be to look here it is an ideal script provided by the PHP.net user guide. Just make sure that you have the GD library installed
You'd want a watermark which can be accomplished with GD
What you are describing is "watermarking". There are tools out there to do this, a lot of image manipulation packages have this feature.
A search for this might lead you to something useful.
Have a look at these PHP tutorials:
Using imagecopymerge() to create a translucent watermark
Adding watermarks to images using alpha channels