gd

Patterned text using php GD library

☆樱花仙子☆ 提交于 2019-11-29 18:12:54
问题 Im trying to create something that looks like this using php gd library: I've figured out how to create simple text using gd library, but im stuck on how to put a patterned text in it. Anybody have any idea on how to do this? 回答1: Yes, this is possible. To do it, you need to uses masks . This website has a nice example: http://www.phpbuilder.com/columns/cash20030526.php3?print_mode=1. Scroll to the bottom of the page, to the "Textures" section for their solution. 回答2: you could create your

php imagettftext and specific emoji

一世执手 提交于 2019-11-29 17:28:56
I've run into a problem drawing emoji that are under the 'Miscellaneous Symbols And Pictographs' unicode block. Here is an example code: <?php header('Content-Type: image/png'); $im = imagecreatetruecolor(290, 60); $grey = imagecolorallocate($im, 200, 200, 200); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 289, 59, $grey); $font = 'seguisym.ttf'; $font = realpath($font); //🌀 is the unicode html entity for a cyclone. It is under 'Miscellaneous Symbols And Pictographs'. $text = "🌀 is a cyclone!"; imagettftext($im, 20, 0, 5, 22, $black, $font, $text); //⛄ is the

How to change the filename displayed in the “Save as…” dialog from .php to .png

非 Y 不嫁゛ 提交于 2019-11-29 15:39:24
A simple PHP script that I picked up from stackoverflow generates a PNG with a transparent background, writes some text on it then directly outputs it to the client browser: $font = 25; $string = 'My Text'; $im = @imagecreatetruecolor(300, 300); imagesavealpha($im, true); imagealphablending($im, false); $white = imagecolorallocatealpha($im, 255, 255, 255, 127); $red = imagecolorallocate($im, 255, 0, 0); imagefill($im, 0, 0, $white); $lime = imagecolorallocate($im, 204, 255, 51); imagettftext($im, $font, 0, 0, 30, $red, "fonts/tt0588m_.ttf", $string); header("Content-type: image/png"); imagepng

PHP/GD - Finding Image Resource Type

跟風遠走 提交于 2019-11-29 15:26:49
问题 Having only a valid GD image resource is it possible to find out the type of the original image? For instance: $image = ImageCreateFromPNG('http://sstatic.net/so/img/logo.png'); Can I get the original image type (PNG) having only the $image variable available? 回答1: I don't think so, no. $image is in GD's internal image format after it has been processed by the ImageCreate() function. 回答2: I am not sure if it can be done from the $image variable, but to get the MimeType, you can usually use

Create animated gif using the GD library

会有一股神秘感。 提交于 2019-11-29 14:49:56
问题 If I've got a bunch of image resources that I made using the GD library in php, or otherwise a bunch of frames, how can I combine these into an animated gif? I've got an array of images and a frames per second I'd like to add.. I can't use ImageMagick or FFMPEG, and I'd prefer to just use the GD library if possible. Apparently "Support for creating GIF animations is also available.", but I can't seem to find the documentation on how to access this from within PHP? 回答1: Well searching on

PHP/GD, how to copy a circle from one image to another?

你。 提交于 2019-11-29 14:12:01
Is there a reasonably straightforward way to copy a circular area from one image resource to another? Something like imagecopymerge except with circles or ovals etc? If possible, I want to avoid having to use pre-created image files (any oval shape should be possible), and if there's transparency colours involved they should naturally leave the rest of the image alone. Reason I'm asking, I have a few classes that allow to apply image operations inside a "selected area" of an image, which works by first deleting that area from a copy of the image, then overlaying the copy back on the original.

Generating image thumbnails using php - without running out of memory

会有一股神秘感。 提交于 2019-11-29 12:42:39
I am currently using a php gd implementation to resize images which constantly runs out of memory - rather quickly. I guess the problem are the php functions, like imagecreatefromstring etc. Is there an easy implementation to resizing images which doesn't use this functions, so I won't have to increase my php.ini memory limit? GD don't use that much memory, so you have other problems in your code. If you resize multiple images and don't call imagedestroy on a newly created image, you run in memory leaks. here is a PHP function for you function make_thumb($src, $dest, $desired_width,$desired_h)

Invalid font filename (imagettfbox)

倖福魔咒の 提交于 2019-11-29 11:23:42
This question has been asked over and over but I could not find the correct answer to my problem... As a little background note, all the code was working perfectly before we moved the class file from /application/lib/class to /library/class ... I have tried to play with GDFONTPATH, relative, absolute paths with and without the file extension to no avail. Here is some of the lines we have tried so far: putenv('GDFONTPATH=' . realpath(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'fonts')); /*1*/ $FontName = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'fonts'.DIRECTORY_SEPARATOR.basename(

php imagettftext letter spacing

爷,独闯天下 提交于 2019-11-29 10:32:07
问题 Does anybody have a function that draws a ttf string (imagettftext) with specified letter spacing? I cannot find any build-in GD function so I think that it should be done letter by letter adding some constant width. Maybe someone have such function already :) ps. the best font will be arial.ttf 回答1: function imagettftextSp($image, $size, $angle, $x, $y, $color, $font, $text, $spacing = 0) { if ($spacing == 0) { imagettftext($image, $size, $angle, $x, $y, $color, $font, $text); } else { $temp

PHP Detecting if source image url link leads to a “broken” image?

旧城冷巷雨未停 提交于 2019-11-29 07:00:47
问题 Suppose you have a thumbnail generator script that accepts source images in the form of a URL. Is there a way to detect if the source URL is "broken" - whether nonexistent or leads to an non-image file? Just brute force using getimagesize() or another PHP GD function is not a solution, since spoofed stray URL's that might not be images at all ( http://example.com/malicious.exe or the same file, but renamed as http://example.com/malicious.jpg ) could be input - such cases could easily be